-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEVA1_2_ALTER.txt
288 lines (277 loc) · 18.4 KB
/
EVA1_2_ALTER.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
Type '\help' or '\?' for help; '\quit' to exit.
MySQL JS > \sql
Switching to SQL mode... Commands end with ;
MySQL SQL > \connect --mc root@localhost
Creating a Classic session to 'root@localhost'
Please provide the password for 'root@localhost': **************
Save password for 'root@localhost'? [Y]es/[N]o/Ne[v]er (default No): n
Fetching schema names for autocompletion... Press ^C to stop.
Your MySQL connection id is 17
Server version: 8.0.22 MySQL Community Server - GPL
No default schema selected; type \use <schema> to set one.
MySQL localhost:3306 ssl SQL > show databases
-> ;
+--------------------+
| Database |
+--------------------+
| hola |
| information_schema |
| mysql |
| performance_schema |
| sakila |
| sys |
| world |
+--------------------+
7 rows in set (0.0012 sec)
MySQL localhost:3306 ssl SQL > use hola
Default schema set to `hola`.
Fetching table and column names from `hola` for auto-completion... Press ^C to stop.
MySQL localhost:3306 ssl hola SQL > create table tabla 1{
->
->
-> ;
ERROR: 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '1{' at line 1
MySQL localhost:3306 ssl hola SQL > create table tabla 1(
-> id bigint unusigned auto_increment, primary key,
->
-> ;
ERROR: 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '1(
id bigint unusigned auto_increment, primary key,' at line 1
MySQL localhost:3306 ssl hola SQL > create table tabla 1( id bigint unusigned auto_increment primary key,
-> nombre varchar(50));
ERROR: 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '1( id bigint unusigned auto_increment primary key,
nombre varchar(50))' at line 1
MySQL localhost:3306 ssl hola SQL > create table tabla1(id bigint unusigned auto_increment primary key, nombre varchar(50));
ERROR: 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'unusigned auto_increment primary key, nombre varchar(50))' at line 1
MySQL localhost:3306 ssl hola SQL > create table tabla1(id bigint unsigned auto_increment primary key, nombre varchar(50));
Query OK, 0 rows affected (1.7913 sec)
MySQL localhost:3306 ssl hola SQL > alter table tabla1
-> ;
Query OK, 0 rows affected (0.1453 sec)
MySQL localhost:3306 ssl hola SQL > alter table tabla1 add edad int;
Query OK, 0 rows affected (1.0664 sec)
Records: 0 Duplicates: 0 Warnings: 0
MySQL localhost:3306 ssl hola SQL > desc tabla1;
+--------+-----------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+--------+-----------------+------+-----+---------+----------------+
| id | bigint unsigned | NO | PRI | NULL | auto_increment |
| nombre | varchar(50) | YES | | NULL | |
| edad | int | YES | | NULL | |
+--------+-----------------+------+-----+---------+----------------+
3 rows in set (0.0579 sec)
MySQL localhost:3306 ssl hola SQL > alter table tabla1 drop edad;
Query OK, 0 rows affected (2.7823 sec)
Records: 0 Duplicates: 0 Warnings: 0
MySQL localhost:3306 ssl hola SQL > desc tabla 1
-> ;
ERROR: 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '1' at line 1
MySQL localhost:3306 ssl hola SQL > desc tabla1
-> ;
+--------+-----------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+--------+-----------------+------+-----+---------+----------------+
| id | bigint unsigned | NO | PRI | NULL | auto_increment |
| nombre | varchar(50) | YES | | NULL | |
+--------+-----------------+------+-----+---------+----------------+
2 rows in set (0.0017 sec)
MySQL localhost:3306 ssl hola SQL > alter table tabla1 add column hapellidos varchar(50) after nombre;
Query OK, 0 rows affected (0.4565 sec)
Records: 0 Duplicates: 0 Warnings: 0
MySQL localhost:3306 ssl hola SQL > desc tabla1;
+------------+-----------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+------------+-----------------+------+-----+---------+----------------+
| id | bigint unsigned | NO | PRI | NULL | auto_increment |
| nombre | varchar(50) | YES | | NULL | |
| hapellidos | varchar(50) | YES | | NULL | |
+------------+-----------------+------+-----+---------+----------------+
3 rows in set (0.0019 sec)
MySQL localhost:3306 ssl hola SQL > alter table tabla1
-> rename column hapellidos to apellidos;
Query OK, 0 rows affected (0.1382 sec)
Records: 0 Duplicates: 0 Warnings: 0
MySQL localhost:3306 ssl hola SQL > des tabla1;
ERROR: 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'des tabla1' at line 1
MySQL localhost:3306 ssl hola SQL > desc tabla1;
+-----------+-----------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-----------+-----------------+------+-----+---------+----------------+
| id | bigint unsigned | NO | PRI | NULL | auto_increment |
| nombre | varchar(50) | YES | | NULL | |
| apellidos | varchar(50) | YES | | NULL | |
+-----------+-----------------+------+-----+---------+----------------+
3 rows in set (0.0581 sec)
MySQL localhost:3306 ssl hola SQL > modify column nombre varchar(50) to varchar(250);
ERROR: 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'modify column nombre varchar(50) to varchar(250)' at line 1
MySQL localhost:3306 ssl hola SQL > modify column nombre varchar(255),
-> modify apellidos varchar(250);
ERROR: 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'modify column nombre varchar(255),
modify apellidos varchar(250)' at line 1
MySQL localhost:3306 ssl hola SQL > alter table tabla 1 modify nombre varchar(255), modify apellidos varchar(250);
ERROR: 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '1 modify nombre varchar(255), modify apellidos varchar(250)' at line 1
MySQL localhost:3306 ssl hola SQL > alter table tabla1 modify nombre varchar(255), modify apellidos varchar(250);
Query OK, 0 rows affected (4.5565 sec)
Records: 0 Duplicates: 0 Warnings: 0
MySQL localhost:3306 ssl hola SQL > desc tabla1
-> ;
+-----------+-----------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-----------+-----------------+------+-----+---------+----------------+
| id | bigint unsigned | NO | PRI | NULL | auto_increment |
| nombre | varchar(255) | YES | | NULL | |
| apellidos | varchar(250) | YES | | NULL | |
+-----------+-----------------+------+-----+---------+----------------+
3 rows in set (0.0531 sec)
MySQL localhost:3306 ssl hola SQL > create table empleados(id bigint unsigned auto_increment primary key, nombre varchar(50)
-> apellido varchar(50), fecha_nacimiento datetime, rfc varchar(13),
-> ciudad_nacimiento text, estado int, numero_tel varchar(50);
ERROR: 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'apellido varchar(50), fecha_nacimiento datetime, rfc varchar(13),
ciudad_nacimie' at line 2
MySQL localhost:3306 ssl hola SQL > create table empleados(id bigint unsigned auto_increment primary key, nombre varchar(50), apellido varchar(50), fecha_nacimiento datetime, rfc varchar(13), ciudad_nacimiento text, estado int, numero_tel varchar(50);
ERROR: 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1
MySQL localhost:3306 ssl hola SQL > create table empleados(id int primary key, nombre varchar(50), apellido varchar(50), fecha_nacimiento datetime, rfc varchar(13), ciudad_nacimiento text, estado int, numero_tel varchar(50);
ERROR: 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1
MySQL localhost:3306 ssl hola SQL > create table empleados(id int primary key, nombre varchar(50), apellido varchar(50), fecha_nacimiento datetime, rfc varchar(13), ciudad_nacimiento text, estado int, numero_tel varchar(50));
Query OK, 0 rows affected (0.9769 sec)
MySQL localhost:3306 ssl hola SQL > desc empleados;
+-------------------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------------------+-------------+------+-----+---------+-------+
| id | int | NO | PRI | NULL | |
| nombre | varchar(50) | YES | | NULL | |
| apellido | varchar(50) | YES | | NULL | |
| fecha_nacimiento | datetime | YES | | NULL | |
| rfc | varchar(13) | YES | | NULL | |
| ciudad_nacimiento | text | YES | | NULL | |
| estado | int | YES | | NULL | |
| numero_tel | varchar(50) | YES | | NULL | |
+-------------------+-------------+------+-----+---------+-------+
8 rows in set (0.0882 sec)
MySQL localhost:3306 ssl hola SQL > alter table empleados add column nss varchar(20) after rfc;
Query OK, 0 rows affected (2.3150 sec)
Records: 0 Duplicates: 0 Warnings: 0
MySQL localhost:3306 ssl hola SQL > desc empleados;
+-------------------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------------------+-------------+------+-----+---------+-------+
| id | int | NO | PRI | NULL | |
| nombre | varchar(50) | YES | | NULL | |
| apellido | varchar(50) | YES | | NULL | |
| fecha_nacimiento | datetime | YES | | NULL | |
| rfc | varchar(13) | YES | | NULL | |
| nss | varchar(20) | YES | | NULL | |
| ciudad_nacimiento | text | YES | | NULL | |
| estado | int | YES | | NULL | |
| numero_tel | varchar(50) | YES | | NULL | |
+-------------------+-------------+------+-----+---------+-------+
9 rows in set (0.0144 sec)
MySQL localhost:3306 ssl hola SQL > alter table empleados add column pais varchar(10) after estado;
Query OK, 0 rows affected (2.5686 sec)
Records: 0 Duplicates: 0 Warnings: 0
MySQL localhost:3306 ssl hola SQL > desc empleados;
+-------------------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------------------+-------------+------+-----+---------+-------+
| id | int | NO | PRI | NULL | |
| nombre | varchar(50) | YES | | NULL | |
| apellido | varchar(50) | YES | | NULL | |
| fecha_nacimiento | datetime | YES | | NULL | |
| rfc | varchar(13) | YES | | NULL | |
| nss | varchar(20) | YES | | NULL | |
| ciudad_nacimiento | text | YES | | NULL | |
| estado | int | YES | | NULL | |
| pais | varchar(10) | YES | | NULL | |
| numero_tel | varchar(50) | YES | | NULL | |
+-------------------+-------------+------+-----+---------+-------+
10 rows in set (0.0018 sec)
MySQL localhost:3306 ssl hola SQL > alter table empleados rename column numero_tel to celular;
Query OK, 0 rows affected (0.4588 sec)
Records: 0 Duplicates: 0 Warnings: 0
MySQL localhost:3306 ssl hola SQL > desc empleados;
+-------------------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------------------+-------------+------+-----+---------+-------+
| id | int | NO | PRI | NULL | |
| nombre | varchar(50) | YES | | NULL | |
| apellido | varchar(50) | YES | | NULL | |
| fecha_nacimiento | datetime | YES | | NULL | |
| rfc | varchar(13) | YES | | NULL | |
| nss | varchar(20) | YES | | NULL | |
| ciudad_nacimiento | text | YES | | NULL | |
| estado | int | YES | | NULL | |
| pais | varchar(10) | YES | | NULL | |
| celular | varchar(50) | YES | | NULL | |
+-------------------+-------------+------+-----+---------+-------+
10 rows in set (0.0671 sec)
MySQL localhost:3306 ssl hola SQL > alter table empleados add column tel_fijo varchar(50);
Query OK, 0 rows affected (1.8604 sec)
Records: 0 Duplicates: 0 Warnings: 0
MySQL localhost:3306 ssl hola SQL > desc empleados;
+-------------------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------------------+-------------+------+-----+---------+-------+
| id | int | NO | PRI | NULL | |
| nombre | varchar(50) | YES | | NULL | |
| apellido | varchar(50) | YES | | NULL | |
| fecha_nacimiento | datetime | YES | | NULL | |
| rfc | varchar(13) | YES | | NULL | |
| nss | varchar(20) | YES | | NULL | |
| ciudad_nacimiento | text | YES | | NULL | |
| estado | int | YES | | NULL | |
| pais | varchar(10) | YES | | NULL | |
| celular | varchar(50) | YES | | NULL | |
| tel_fijo | varchar(50) | YES | | NULL | |
+-------------------+-------------+------+-----+---------+-------+
11 rows in set (0.0020 sec)
MySQL localhost:3306 ssl hola SQL > alter table empleados add column id_depto int after id;
Query OK, 0 rows affected (3.1300 sec)
Records: 0 Duplicates: 0 Warnings: 0
MySQL localhost:3306 ssl hola SQL > desc empleados;
+-------------------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------------------+-------------+------+-----+---------+-------+
| id | int | NO | PRI | NULL | |
| id_depto | int | YES | | NULL | |
| nombre | varchar(50) | YES | | NULL | |
| apellido | varchar(50) | YES | | NULL | |
| fecha_nacimiento | datetime | YES | | NULL | |
| rfc | varchar(13) | YES | | NULL | |
| nss | varchar(20) | YES | | NULL | |
| ciudad_nacimiento | text | YES | | NULL | |
| estado | int | YES | | NULL | |
| pais | varchar(10) | YES | | NULL | |
| celular | varchar(50) | YES | | NULL | |
| tel_fijo | varchar(50) | YES | | NULL | |
+-------------------+-------------+------+-----+---------+-------+
12 rows in set (0.0051 sec)
MySQL localhost:3306 ssl hola SQL > alter table empleados add column iniciales varchar(10) after apellido;
Query OK, 0 rows affected (1.8967 sec)
Records: 0 Duplicates: 0 Warnings: 0
MySQL localhost:3306 ssl hola SQL > desc empleados;
+-------------------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------------------+-------------+------+-----+---------+-------+
| id | int | NO | PRI | NULL | |
| id_depto | int | YES | | NULL | |
| nombre | varchar(50) | YES | | NULL | |
| apellido | varchar(50) | YES | | NULL | |
| iniciales | varchar(10) | YES | | NULL | |
| fecha_nacimiento | datetime | YES | | NULL | |
| rfc | varchar(13) | YES | | NULL | |
| nss | varchar(20) | YES | | NULL | |
| ciudad_nacimiento | text | YES | | NULL | |
| estado | int | YES | | NULL | |
| pais | varchar(10) | YES | | NULL | |
| celular | varchar(50) | YES | | NULL | |
| tel_fijo | varchar(50) | YES | | NULL | |
+-------------------+-------------+------+-----+---------+-------+
13 rows in set (0.0020 sec)
MySQL localhost:3306 ssl hola SQL > show tables;
+----------------+
| Tables_in_hola |
+----------------+
| empleados |
| tabla1 |
+----------------+
2 rows in set (0.0231 sec)