· 8 years ago · Mar 16, 2018, 01:58 PM
1MySQL Shell 1.0.11
2
3Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
4
5Oracle is a registered trademark of Oracle Corporation and/or its
6affiliates. Other names may be trademarks of their respective
7owners.
8
9Type '\help' or '\?' for help; '\quit' to exit.
10
11Currently in JavaScript mode. Use \sql to switch to SQL mode and execute queries.
12mysql-js> \sql
13Switching to SQL mode... Commands end with ;
14mysql-sql> \connect -c root@loclahoste
15Creating a Classic Session to 'root@loclahoste'
16Enter password: ***********
17ERROR: 2005 (HY000): Unknown MySQL server host 'loclahoste' (0)
18mysql-sql> \connect -c root@localhost
19Creating a Classic Session to 'root@localhost'
20Enter password: ***********
21Your MySQL connection id is 12
22Server version: 5.7.21-log MySQL Community Server (GPL)
23No default schema selected; type \use <schema> to set one.
24mysql-sql> show databases;
25+--------------------+
26| Database |
27+--------------------+
28| information_schema |
29| ejercicios |
30| itchii |
31| mundo |
32| mysql |
33| performance_schema |
34| practica5 |
35| pruebaexamen |
36| sakila |
37| sys |
38| world |
39+--------------------+
4011 rows in set (0.54 sec)
41mysql-sql> drop ejercicios;
42ERROR: 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 'ejercicios'
43at line 1
44mysql-sql> drop database ejercicios;
45Query OK, 5 rows affected (6.98 sec)
46mysql-sql> show databases;
47+--------------------+
48| Database |
49+--------------------+
50| information_schema |
51| itchii |
52| mundo |
53| mysql |
54| performance_schema |
55| practica5 |
56| pruebaexamen |
57| sakila |
58| sys |
59| world |
60+--------------------+
6110 rows in set (0.00 sec)
62mysql-sql> srop user "usu_eva1"@"localhost";
63ERROR: 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 'srop user "u
64su_eva1"@"localhost"' at line 1
65mysql-sql> drop user "usu_eva1"@"localhost";
66Query OK, 0 rows affected (1.08 sec)
67mysql-sql> create user "usu_eva1"@"localhost" identified by "qqqq.123";
68Query OK, 0 rows affected (0.13 sec)
69mysql-sql> create database ejercicios;
70Query OK, 1 row affected (0.06 sec)
71mysql-sql> create table alumno(
72 ... alumno_id int not null primary key unique,
73 ... nom_alumno varchar(50) not null,
74 ... ape_pat_alumno varchar(50) not null,
75 ... ape_mat_alumno varchar(50) not null,
76 ... no_control_alumno int not null unique);
77ERROR: 1046 (3D000): No database selected
78mysql-sql> \use ejerecicios
79MySQL Error (1049): Unknown database 'ejerecicios'
80mysql-sql> create database ejercicios;
81ERROR: 1007 (HY000): Can't create database 'ejercicios'; database exists
82mysql-sql> \use ejercicios
83Schema set to `ejercicios`.
84mysql-sql> create table alumno(
85 ... alumno_id int not null primary key unique,
86 ... nom_alumno varchar(50) not null,
87 ... ape_pat_alumno varchar(50) not null,
88 ... ape_mat_alumno varchar(50) not null,
89 ... no_control_alumno int not null unique);
90Query OK, 0 rows affected (1.80 sec)
91mysql-sql> desc alumno;
92+-------------------+-------------+------+-----+---------+-------+
93| Field | Type | Null | Key | Default | Extra |
94+-------------------+-------------+------+-----+---------+-------+
95| alumno_id | int(11) | NO | PRI | null | |
96| nom_alumno | varchar(50) | NO | | null | |
97| ape_pat_alumno | varchar(50) | NO | | null | |
98| ape_mat_alumno | varchar(50) | NO | | null | |
99| no_control_alumno | int(11) | NO | UNI | null | |
100+-------------------+-------------+------+-----+---------+-------+
1015 rows in set (0.22 sec)
102mysql-sql> create table if not exists alumno(
103 ... alumno_id int not null primary key unique,
104 ... nom_alumno varchar(50) not null,
105 ... ape_pat_alumno varchar(50) not null,
106 ... ape_mat_alumno varchar(50) not null,
107 ... no_control_alumno int not null unique);
108Query OK, 0 rows affected, 1 warning (0.00 sec)
109Note (code 1050): Table 'alumno' already exists
110mysql-sql> create table dup_alumno like alumno;
111Query OK, 0 rows affected (0.94 sec)
112mysql-sql> show tables;
113+----------------------+
114| Tables_in_ejercicios |
115+----------------------+
116| alumno |
117| dup_alumno |
118+----------------------+
1192 rows in set (0.00 sec)
120mysql-sql> desc dup_alumno;
121+-------------------+-------------+------+-----+---------+-------+
122| Field | Type | Null | Key | Default | Extra |
123+-------------------+-------------+------+-----+---------+-------+
124| alumno_id | int(11) | NO | PRI | null | |
125| nom_alumno | varchar(50) | NO | | null | |
126| ape_pat_alumno | varchar(50) | NO | | null | |
127| ape_mat_alumno | varchar(50) | NO | | null | |
128| no_control_alumno | int(11) | NO | UNI | null | |
129+-------------------+-------------+------+-----+---------+-------+
1305 rows in set (0.11 sec)
131mysql-sql> alter table alumno add(
132 ... semestre_alumno int not null,
133 ... edad_alumno int,
134 ... telefono alumno int,
135 ... ;
136ERROR: 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 'alumno int,'
137 at line 4
138mysql-sql> alter table alumno add(
139 ... semestre_alumno int not null,
140 ... edad_alumno int,
141 ... telefono_alumno int,
142 ... correo_electr_alumno varchar(50),
143 ... especilidad varchar(50) not null);
144Query OK, 0 rows affected (1.94 sec)
145
146Records: 0 Duplicates: 0 Warnings: 0
147mysql-sql> desc alumno;
148+----------------------+-------------+------+-----+---------+-------+
149| Field | Type | Null | Key | Default | Extra |
150+----------------------+-------------+------+-----+---------+-------+
151| alumno_id | int(11) | NO | PRI | null | |
152| nom_alumno | varchar(50) | NO | | null | |
153| ape_pat_alumno | varchar(50) | NO | | null | |
154| ape_mat_alumno | varchar(50) | NO | | null | |
155| no_control_alumno | int(11) | NO | UNI | null | |
156| semestre_alumno | int(11) | NO | | null | |
157| edad_alumno | int(11) | YES | | null | |
158| telefono_alumno | int(11) | YES | | null | |
159| correo_electr_alumno | varchar(50) | YES | | null | |
160| especilidad | varchar(50) | NO | | null | |
161+----------------------+-------------+------+-----+---------+-------+
16210 rows in set (0.00 sec)
163mysql-sql> create table copia_alumno like alumno;
164Query OK, 0 rows affected (0.65 sec)
165mysql-sql> insert copia_alumno select * from alumno;
166Query OK, 0 rows affected (0.10 sec)
167
168Records: 0 Duplicates: 0 Warnings: 0
169mysql-sql> desc copia_alumno;
170+----------------------+-------------+------+-----+---------+-------+
171| Field | Type | Null | Key | Default | Extra |
172+----------------------+-------------+------+-----+---------+-------+
173| alumno_id | int(11) | NO | PRI | null | |
174| nom_alumno | varchar(50) | NO | | null | |
175| ape_pat_alumno | varchar(50) | NO | | null | |
176| ape_mat_alumno | varchar(50) | NO | | null | |
177| no_control_alumno | int(11) | NO | UNI | null | |
178| semestre_alumno | int(11) | NO | | null | |
179| edad_alumno | int(11) | YES | | null | |
180| telefono_alumno | int(11) | YES | | null | |
181| correo_electr_alumno | varchar(50) | YES | | null | |
182| especilidad | varchar(50) | NO | | null | |
183+----------------------+-------------+------+-----+---------+-------+
18410 rows in set (0.00 sec)
185mysql-sql> create table carrera(
186 ... carrera_id int not null,
187 ... nombre_carrera varchar(50) not null,
188 ... creditos_carrera int not null);
189Query OK, 0 rows affected (0.46 sec)
190mysql-sql> desc carrera;
191+------------------+-------------+------+-----+---------+-------+
192| Field | Type | Null | Key | Default | Extra |
193+------------------+-------------+------+-----+---------+-------+
194| carrera_id | int(11) | NO | | null | |
195| nombre_carrera | varchar(50) | NO | | null | |
196| creditos_carrera | int(11) | NO | | null | |
197+------------------+-------------+------+-----+---------+-------+
1983 rows in set (0.03 sec)
199mysql-sql> create table docentes(
200 ... docentes_id int not null,
201 ... nombre_docente varchar(50) not null,
202 ... ape_pat_docente varchar(50) not null,
203 ... ape_mat_docente varchar(50) not null,
204 ... horas_plaza int not null default "8",
205 ... departamento_docente ENUM("SISTEMAS Y COMPUTACION", "INGENIERIA INDUSTRIAL", "CIENCIAS DE LA TIERRA", "CIENCIAS ECONOMICO ADMINISTRATIVAS", "CIENCIAS BASICAS
206") not null);
207Query OK, 0 rows affected (0.54 sec)
208mysql-sql> desc docentes;
209+----------------------+----------------------------------------------------------------------------------------------------------------------------------------+------+
210-----+---------+-------+
211| Field | Type | Null |
212 Key | Default | Extra |
213+----------------------+----------------------------------------------------------------------------------------------------------------------------------------+------+
214-----+---------+-------+
215| docentes_id | int(11) | NO |
216 | null | |
217| nombre_docente | varchar(50) | NO |
218 | null | |
219| ape_pat_docente | varchar(50) | NO |
220 | null | |
221| ape_mat_docente | varchar(50) | NO |
222 | null | |
223| horas_plaza | int(11) | NO |
224 | 8 | |
225| departamento_docente | enum('SISTEMAS Y COMPUTACION','INGENIERIA INDUSTRIAL','CIENCIAS DE LA TIERRA','CIENCIAS ECONOMICO ADMINISTRATIVAS','CIENCIAS BASICAS') | NO |
226 | null | |
227+----------------------+----------------------------------------------------------------------------------------------------------------------------------------+------+
228-----+---------+-------+
2296 rows in set (0.03 sec)
230mysql-sql> create table institutos(
231 ... instituto_id int not null,
232 ... nombre_instituto varchar(50) not null unique,
233 ... :;
234ERROR: 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 4
235
236mysql-sql> create table institutos(
237 ... instituto_id int,
238 ... nombre_instituto varchar(50) unique,
239 ... estado_instituto ENUM("Aguascalientes", "Baja california", "Baja california sur", "Campeche", "Chiapas", "Chihuahua", "Ciudad de México", "Coahuila", "Colima
240", "Durango", "Guanajuato", "Guerrero", "Hidalgo", "Jalisco", "México", "Michoacán", "Morelos", "Nayarit", "Nuevo león", "Oaxaca", "Puebla", "Queretaro", "Quintana roo"
241, "San Luis PotosÃ", "Sinaloa", "Sonora", "Tabasco", "Tamaulipas", "Tlaxcala", "Veracruz", "Yucatán", "Zacatecas");
242ERROR: 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 4
243mysql-sql> create table institutos(
244 ... instituto_id int,
245 ... nombre_instituto varchar(50) unique,
246 ... estado_instituto ENUM("Aguascalientes", "Baja california", "Baja california sur", "Campeche", "Chiapas", "Chihuahua", "Ciudad de México", "Coahuila", "Colima
247", "Durango", "Guanajuato", "Guerrero", "Hidalgo", "Jalisco", "México", "Michoacán", "Morelos", "Nayarit", "Nuevo león", "Oaxaca", "Puebla", "Queretaro", "Quintana roo"
248, "San Luis PotosÃ", "Sinaloa", "Sonora", "Tabasco", "Tamaulipas", "Tlaxcala", "Veracruz", "Yucatán", "Zacatecas"));
249Query OK, 0 rows affected (0.63 sec)
250mysql-sql> desc institutos;
251+------------------+----------------------------------------------------------------------------------------------------------------------------------------------------
252------------------------------------------------------------------------------------------------------------------------------------------------------------------------
253-----------------------------------------------------------------------------+------+-----+---------+-------+
254| Field | Type
255
256 | Null | Key | Default | Extra |
257+------------------+----------------------------------------------------------------------------------------------------------------------------------------------------
258------------------------------------------------------------------------------------------------------------------------------------------------------------------------
259-----------------------------------------------------------------------------+------+-----+---------+-------+
260| instituto_id | int(11)
261
262 | YES | | null | |
263| nombre_instituto | varchar(50)
264
265 | YES | UNI | null | |
266| estado_instituto | enum('Aguascalientes','Baja california','Baja california sur','Campeche','Chiapas','Chihuahua','Ciudad de México','Coahuila','Colima','Durango','Gu
267anajuato','Guerrero','Hidalgo','Jalisco','México','Michoacán','Morelos','Nayarit','Nuevo león','Oaxaca','Puebla','Queretaro','Quintana roo','San Luis PotosÃ','Sinaloa',
268'Sonora','Tabasco','Tamaulipas','Tlaxcala','Veracruz','Yucatán','Zacatecas') | YES | | null | |
269+------------------+----------------------------------------------------------------------------------------------------------------------------------------------------
270------------------------------------------------------------------------------------------------------------------------------------------------------------------------
271-----------------------------------------------------------------------------+------+-----+---------+-------+
2723 rows in set (0.10 sec)
273 ... nombre_carrera varchar(50) not null,
274 ... creditos_carrera int not null);
275Query OK, 0 rows affected (0.46 sec)
276mysql-sql> desc carrera;
277+------------------+-------------+------+-----+---------+-------+
278| Field | Type | Null | Key | Default | Extra |
279+------------------+-------------+------+-----+---------+-------+
280| carrera_id | int(11) | NO | | null | |
281| nombre_carrera | varchar(50) | NO | | null | |
282| creditos_carrera | int(11) | NO | | null | |
283+------------------+-------------+------+-----+---------+-------+
2843 rows in set (0.03 sec)
285mysql-sql> create table docentes(
286 ... docentes_id int not null,
287 ... nombre_docente varchar(50) not null,
288 ... ape_pat_docente varchar(50) not null,
289 ... ape_mat_docente varchar(50) not null,
290 ... horas_plaza int not null default "8",
291 ... departamento_docente ENUM("SISTEMAS Y COMPUTACION", "INGENIERIA INDUSTRIAL", "CIENCIAS DE LA TIERRA", "CIENCIAS ECONOMICO ADMINISTRATIVAS", "CIENCIAS BASICAS
292") not null);
293Query OK, 0 rows affected (0.54 sec)
294mysql-sql> desc docentes;
295+----------------------+----------------------------------------------------------------------------------------------------------------------------------------+------+
296-----+---------+-------+
297| Field | Type | Null |
298 Key | Default | Extra |
299+----------------------+----------------------------------------------------------------------------------------------------------------------------------------+------+
300-----+---------+-------+
301| docentes_id | int(11) | NO |
302 | null | |
303| nombre_docente | varchar(50) | NO |
304 | null | |
305| ape_pat_docente | varchar(50) | NO |
306 | null | |
307| ape_mat_docente | varchar(50) | NO |
308 | null | |
309| horas_plaza | int(11) | NO |
310 | 8 | |
311| departamento_docente | enum('SISTEMAS Y COMPUTACION','INGENIERIA INDUSTRIAL','CIENCIAS DE LA TIERRA','CIENCIAS ECONOMICO ADMINISTRATIVAS','CIENCIAS BASICAS') | NO |
312 | null | |
313+----------------------+----------------------------------------------------------------------------------------------------------------------------------------+------+
314-----+---------+-------+
3156 rows in set (0.03 sec)
316mysql-sql> create table institutos(
317 ... instituto_id int not null,
318 ... nombre_instituto varchar(50) not null unique,
319 ... :;
320ERROR: 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 4
321
322mysql-sql> create table institutos(
323 ... instituto_id int,
324 ... nombre_instituto varchar(50) unique,
325 ... estado_instituto ENUM("Aguascalientes", "Baja california", "Baja california sur", "Campeche", "Chiapas", "Chihuahua", "Ciudad de México", "Coahuila", "Colima
326", "Durango", "Guanajuato", "Guerrero", "Hidalgo", "Jalisco", "México", "Michoacán", "Morelos", "Nayarit", "Nuevo león", "Oaxaca", "Puebla", "Queretaro", "Quintana roo"
327, "San Luis PotosÃ", "Sinaloa", "Sonora", "Tabasco", "Tamaulipas", "Tlaxcala", "Veracruz", "Yucatán", "Zacatecas");
328ERROR: 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 4
329mysql-sql> create table institutos(
330 ... instituto_id int,
331 ... nombre_instituto varchar(50) unique,
332 ... estado_instituto ENUM("Aguascalientes", "Baja california", "Baja california sur", "Campeche", "Chiapas", "Chihuahua", "Ciudad de México", "Coahuila", "Colima
333", "Durango", "Guanajuato", "Guerrero", "Hidalgo", "Jalisco", "México", "Michoacán", "Morelos", "Nayarit", "Nuevo león", "Oaxaca", "Puebla", "Queretaro", "Quintana roo"
334, "San Luis PotosÃ", "Sinaloa", "Sonora", "Tabasco", "Tamaulipas", "Tlaxcala", "Veracruz", "Yucatán", "Zacatecas"));
335Query OK, 0 rows affected (0.63 sec)
336mysql-sql> desc institutos;
337+------------------+----------------------------------------------------------------------------------------------------------------------------------------------------
338------------------------------------------------------------------------------------------------------------------------------------------------------------------------
339-----------------------------------------------------------------------------+------+-----+---------+-------+
340| Field | Type
341
342 | Null | Key | Default | Extra |
343+------------------+----------------------------------------------------------------------------------------------------------------------------------------------------
344------------------------------------------------------------------------------------------------------------------------------------------------------------------------
345-----------------------------------------------------------------------------+------+-----+---------+-------+
346| instituto_id | int(11)
347
348 | YES | | null | |
349| nombre_instituto | varchar(50)
350
351 | YES | UNI | null | |
352| estado_instituto | enum('Aguascalientes','Baja california','Baja california sur','Campeche','Chiapas','Chihuahua','Ciudad de México','Coahuila','Colima','Durango','Gu
353anajuato','Guerrero','Hidalgo','Jalisco','México','Michoacán','Morelos','Nayarit','Nuevo león','Oaxaca','Puebla','Queretaro','Quintana roo','San Luis PotosÃ','Sinaloa',
354'Sonora','Tabasco','Tamaulipas','Tlaxcala','Veracruz','Yucatán','Zacatecas') | YES | | null | |
355+------------------+----------------------------------------------------------------------------------------------------------------------------------------------------
356------------------------------------------------------------------------------------------------------------------------------------------------------------------------
357-----------------------------------------------------------------------------+------+-----+---------+-------+
3583 rows in set (0.10 sec)
359mysql-sql> show tables;
360+----------------------+
361| Tables_in_ejercicios |
362+----------------------+
363| alumno |
364| carrera |
365| copia_alumno |
366| docentes |
367| dup_alumno |
368| institutos |
369+----------------------+
3706 rows in set (0.00 sec)
371mysql-sql> alter table alumno modify column alumno_id int not null unique;
372Query OK, 0 rows affected, 1 warning (0.65 sec)
373
374Records: 0 Duplicates: 0 Warnings: 1
375Warning (code 1831): Duplicate index 'alumno_id_2' defined on the table 'ejercicios.alumno'. This is deprecated and will be disallowed in a future release.
376mysql-sql> desc alumno;
377+----------------------+-------------+------+-----+---------+-------+
378| Field | Type | Null | Key | Default | Extra |
379+----------------------+-------------+------+-----+---------+-------+
380| alumno_id | int(11) | NO | PRI | null | |
381| nom_alumno | varchar(50) | NO | | null | |
382| ape_pat_alumno | varchar(50) | NO | | null | |
383| ape_mat_alumno | varchar(50) | NO | | null | |
384| no_control_alumno | int(11) | NO | UNI | null | |
385| semestre_alumno | int(11) | NO | | null | |
386| edad_alumno | int(11) | YES | | null | |
387| telefono_alumno | int(11) | YES | | null | |
388| correo_electr_alumno | varchar(50) | YES | | null | |
389| especilidad | varchar(50) | NO | | null | |
390+----------------------+-------------+------+-----+---------+-------+
39110 rows in set (0.00 sec)
392mysql-sql> alter table alumno modify column alumno_id int;
393Query OK, 0 rows affected (0.17 sec)
394
395Records: 0 Duplicates: 0 Warnings: 0
396mysql-sql> alter table alumno modify column alumno_id int not null unique;
397Query OK, 0 rows affected, 1 warning (0.46 sec)
398
399Records: 0 Duplicates: 0 Warnings: 1
400Warning (code 1831): Duplicate index 'alumno_id_3' defined on the table 'ejercicios.alumno'. This is deprecated and will be disallowed in a future release.
401mysql-sql> desc alumno;
402+----------------------+-------------+------+-----+---------+-------+
403| Field | Type | Null | Key | Default | Extra |
404+----------------------+-------------+------+-----+---------+-------+
405| alumno_id | int(11) | NO | PRI | null | |
406| nom_alumno | varchar(50) | NO | | null | |
407| ape_pat_alumno | varchar(50) | NO | | null | |
408| ape_mat_alumno | varchar(50) | NO | | null | |
409| no_control_alumno | int(11) | NO | UNI | null | |
410| semestre_alumno | int(11) | NO | | null | |
411| edad_alumno | int(11) | YES | | null | |
412| telefono_alumno | int(11) | YES | | null | |
413| correo_electr_alumno | varchar(50) | YES | | null | |
414| especilidad | varchar(50) | NO | | null | |
415+----------------------+-------------+------+-----+---------+-------+
41610 rows in set (0.00 sec)
417mysql-sql> alter table alumno alter column alumno_id int not null unique;
418ERROR: 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 'int not null
419 unique' at line 1
420mysql-sql> alter table alumno modify alumno_id int not null unique;
421Query OK, 0 rows affected, 1 warning (0.49 sec)
422
423Records: 0 Duplicates: 0 Warnings: 1
424Warning (code 1831): Duplicate index 'alumno_id_4' defined on the table 'ejercicios.alumno'. This is deprecated and will be disallowed in a future release.
425mysql-sql> desc alumno;
426+----------------------+-------------+------+-----+---------+-------+
427| Field | Type | Null | Key | Default | Extra |
428+----------------------+-------------+------+-----+---------+-------+
429| alumno_id | int(11) | NO | PRI | null | |
430| nom_alumno | varchar(50) | NO | | null | |
431| ape_pat_alumno | varchar(50) | NO | | null | |
432| ape_mat_alumno | varchar(50) | NO | | null | |
433| no_control_alumno | int(11) | NO | UNI | null | |
434| semestre_alumno | int(11) | NO | | null | |
435| edad_alumno | int(11) | YES | | null | |
436| telefono_alumno | int(11) | YES | | null | |
437| correo_electr_alumno | varchar(50) | YES | | null | |
438| especilidad | varchar(50) | NO | | null | |
439+----------------------+-------------+------+-----+---------+-------+
44010 rows in set (0.00 sec)
441mysql-sql> select * from alumno_id;
442ERROR: 1146 (42S02): Table 'ejercicios.alumno_id' doesn't exist
443mysql-sql> select * from alumno.alumno_id;
444ERROR: 1146 (42S02): Table 'alumno.alumno_id' doesn't exist
445mysql-sql> alter table alumno rename nom_alumno to nombre_alumno;
446ERROR: 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 'to nombre_al
447umno' at line 1
448mysql-sql> alter table alumno rename nom_alumno to nombre_alumno;
449ERROR: 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 'to nombre_al
450umno' at line 1
451mysql-sql> alter table alumno RENAME nom_alumno TO nombre_alumno;
452ERROR: 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 'TO nombre_al
453umno' at line 1
454mysql-sql> alter table alumno change "nom_alumno" "nombre_alumno";
455ERROR: 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 '"nom_alumno"
456 "nombre_alumno"' at line 1
457mysql-sql> alter table alumno change nom_alumno nombre_alumno;
458ERROR: 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
459mysql-sql> alter table alumno add unique(alumno_id);
460Query OK, 0 rows affected, 1 warning (0.73 sec)
461
462Records: 0 Duplicates: 0 Warnings: 1
463Warning (code 1831): Duplicate index 'alumno_id_5' defined on the table 'ejercicios.alumno'. This is deprecated and will be disallowed in a future release.
464mysql-sql> #Declare como no nullo y único alumno_id al prinicipio, pero aquà esta el código
465mysql-sql> alter table alumno change alumno_id alumno_id not null;
466ERROR: 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 'not null' at
467 line 1
468mysql-sql> alter table alumno change alumno_id alumno_id int not null;
469Query OK, 0 rows affected (0.13 sec)
470
471Records: 0 Duplicates: 0 Warnings: 0
472mysql-sql> desc alumno;
473+----------------------+-------------+------+-----+---------+-------+
474| Field | Type | Null | Key | Default | Extra |
475+----------------------+-------------+------+-----+---------+-------+
476| alumno_id | int(11) | NO | PRI | null | |
477| nom_alumno | varchar(50) | NO | | null | |
478| ape_pat_alumno | varchar(50) | NO | | null | |
479| ape_mat_alumno | varchar(50) | NO | | null | |
480| no_control_alumno | int(11) | NO | UNI | null | |
481| semestre_alumno | int(11) | NO | | null | |
482| edad_alumno | int(11) | YES | | null | |
483| telefono_alumno | int(11) | YES | | null | |
484| correo_electr_alumno | varchar(50) | YES | | null | |
485| especilidad | varchar(50) | NO | | null | |
486+----------------------+-------------+------+-----+---------+-------+
48710 rows in set (0.00 sec)
488mysql-sql> alter table alumno add unique(alumno_id);
489Query OK, 0 rows affected, 1 warning (0.61 sec)
490
491Records: 0 Duplicates: 0 Warnings: 1
492Warning (code 1831): Duplicate index 'alumno_id_6' defined on the table 'ejercicios.alumno'. This is deprecated and will be disallowed in a future release.
493mysql-sql> alter table alumno change nom_alumno nombre_alumno varchar(50);
494Query OK, 0 rows affected (1.81 sec)
495
496Records: 0 Duplicates: 0 Warnings: 0
497mysql-sql> desc alumno;
498+----------------------+-------------+------+-----+---------+-------+
499| Field | Type | Null | Key | Default | Extra |
500+----------------------+-------------+------+-----+---------+-------+
501| alumno_id | int(11) | NO | PRI | null | |
502| nombre_alumno | varchar(50) | YES | | null | |
503| ape_pat_alumno | varchar(50) | NO | | null | |
504| ape_mat_alumno | varchar(50) | NO | | null | |
505| no_control_alumno | int(11) | NO | UNI | null | |
506| semestre_alumno | int(11) | NO | | null | |
507| edad_alumno | int(11) | YES | | null | |
508| telefono_alumno | int(11) | YES | | null | |
509| correo_electr_alumno | varchar(50) | YES | | null | |
510| especilidad | varchar(50) | NO | | null | |
511+----------------------+-------------+------+-----+---------+-------+
51210 rows in set (0.00 sec)
513mysql-sql> alter table alumno change nombre_alumno nombre_alumno not null;
514ERROR: 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 'not null' at
515 line 1
516mysql-sql> alter table alumno change nombre_alumno nombre_alumno vatchar(50) not null;
517ERROR: 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 'vatchar(50)
518not null' at line 1
519mysql-sql> alter table alumno change nombre_alumno nombre_alumno varchar(50) not null;
520Query OK, 0 rows affected (1.29 sec)
521
522Records: 0 Duplicates: 0 Warnings: 0
523mysql-sql> alter table alumno change ape_pat_alumno apellido_pat_alumno varchar(50) not null;
524Query OK, 0 rows affected (0.20 sec)
525
526Records: 0 Duplicates: 0 Warnings: 0
527mysql-sql> alter table alumno change ape_mat_alumno apellido_mat_alumno varchar(50) not null;
528Query OK, 0 rows affected (0.17 sec)
529
530Records: 0 Duplicates: 0 Warnings: 0
531mysql-sql> desc alumno;
532+----------------------+-------------+------+-----+---------+-------+
533| Field | Type | Null | Key | Default | Extra |
534+----------------------+-------------+------+-----+---------+-------+
535| alumno_id | int(11) | NO | PRI | null | |
536| nombre_alumno | varchar(50) | NO | | null | |
537| apellido_pat_alumno | varchar(50) | NO | | null | |
538| apellido_mat_alumno | varchar(50) | NO | | null | |
539| no_control_alumno | int(11) | NO | UNI | null | |
540| semestre_alumno | int(11) | NO | | null | |
541| edad_alumno | int(11) | YES | | null | |
542| telefono_alumno | int(11) | YES | | null | |
543| correo_electr_alumno | varchar(50) | YES | | null | |
544| especilidad | varchar(50) | NO | | null | |
545+----------------------+-------------+------+-----+---------+-------+
54610 rows in set (0.00 sec)
547mysql-sql> alter table alumno change no_control_alumno no_control_alumno int not null;
548Query OK, 0 rows affected (0.19 sec)
549
550Records: 0 Duplicates: 0 Warnings: 0
551mysql-sql> alter table alumno add unique(no_control_alumno);
552Query OK, 0 rows affected, 1 warning (0.60 sec)
553
554Records: 0 Duplicates: 0 Warnings: 1
555Warning (code 1831): Duplicate index 'no_control_alumno_2' defined on the table 'ejercicios.alumno'. This is deprecated and will be disallowed in a future release.
556mysql-sql> show tables;
557+----------------------+
558| Tables_in_ejercicios |
559+----------------------+
560| alumno |
561| carrera |
562| copia_alumno |
563| docentes |
564| dup_alumno |
565| institutos |
566+----------------------+
5676 rows in set (0.00 sec)
568mysql-sql> alter table ciudadano add primary key(alumno_id);
569ERROR: 1146 (42S02): Table 'ejercicios.ciudadano' doesn't exist
570mysql-sql> alter table alumno add primary key(alumno_id);
571ERROR: 1068 (42000): Multiple primary key defined
572mysql-sql> alter table alumno change alumno_id alumno_id
573ERROR: 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 'not null' at
574 line 1
575mysql-sql> alter table alumno change alumno_id alumno_id int not null;
576Query OK, 0 rows affected (0.13 sec)
577
578Records: 0 Duplicates: 0 Warnings: 0
579mysql-sql> desc alumno;
580+----------------------+-------------+------+-----+---------+-------+
581| Field | Type | Null | Key | Default | Extra |
582+----------------------+-------------+------+-----+---------+-------+
583| alumno_id | int(11) | NO | PRI | null | |
584| nom_alumno | varchar(50) | NO | | null | |
585| ape_pat_alumno | varchar(50) | NO | | null | |
586| ape_mat_alumno | varchar(50) | NO | | null | |
587| no_control_alumno | int(11) | NO | UNI | null | |
588| semestre_alumno | int(11) | NO | | null | |
589| edad_alumno | int(11) | YES | | null | |
590| telefono_alumno | int(11) | YES | | null | |
591| correo_electr_alumno | varchar(50) | YES | | null | |
592| especilidad | varchar(50) | NO | | null | |
593+----------------------+-------------+------+-----+---------+-------+
59410 rows in set (0.00 sec)
595mysql-sql> alter table alumno add unique(alumno_id);
596Query OK, 0 rows affected, 1 warning (0.61 sec)
597
598Records: 0 Duplicates: 0 Warnings: 1
599Warning (code 1831): Duplicate index 'alumno_id_6' defined on the table 'ejercicios.alumno'. This is deprecated and will be disallowed in a future release.
600mysql-sql> alter table alumno change nom_alumno nombre_alumno varchar(50);
601Query OK, 0 rows affected (1.81 sec)
602
603Records: 0 Duplicates: 0 Warnings: 0
604mysql-sql> desc alumno;
605+----------------------+-------------+------+-----+---------+-------+
606| Field | Type | Null | Key | Default | Extra |
607+----------------------+-------------+------+-----+---------+-------+
608| alumno_id | int(11) | NO | PRI | null | |
609| nombre_alumno | varchar(50) | YES | | null | |
610| ape_pat_alumno | varchar(50) | NO | | null | |
611| ape_mat_alumno | varchar(50) | NO | | null | |
612| no_control_alumno | int(11) | NO | UNI | null | |
613| semestre_alumno | int(11) | NO | | null | |
614| edad_alumno | int(11) | YES | | null | |
615| telefono_alumno | int(11) | YES | | null | |
616| correo_electr_alumno | varchar(50) | YES | | null | |
617| especilidad | varchar(50) | NO | | null | |
618+----------------------+-------------+------+-----+---------+-------+
61910 rows in set (0.00 sec)
620mysql-sql> alter table alumno change nombre_alumno nombre_alumno not null;
621ERROR: 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 'not null' at
622 line 1
623mysql-sql> alter table alumno change nombre_alumno nombre_alumno vatchar(50) not null;
624ERROR: 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 'vatchar(50)
625not null' at line 1
626mysql-sql> alter table alumno change nombre_alumno nombre_alumno varchar(50) not null;
627Query OK, 0 rows affected (1.29 sec)
628
629Records: 0 Duplicates: 0 Warnings: 0
630mysql-sql> alter table alumno change ape_pat_alumno apellido_pat_alumno varchar(50) not null;
631Query OK, 0 rows affected (0.20 sec)
632
633Records: 0 Duplicates: 0 Warnings: 0
634mysql-sql> alter table alumno change ape_mat_alumno apellido_mat_alumno varchar(50) not null;
635Query OK, 0 rows affected (0.17 sec)
636
637Records: 0 Duplicates: 0 Warnings: 0
638mysql-sql> desc alumno;
639+----------------------+-------------+------+-----+---------+-------+
640| Field | Type | Null | Key | Default | Extra |
641+----------------------+-------------+------+-----+---------+-------+
642| alumno_id | int(11) | NO | PRI | null | |
643| nombre_alumno | varchar(50) | NO | | null | |
644| apellido_pat_alumno | varchar(50) | NO | | null | |
645| apellido_mat_alumno | varchar(50) | NO | | null | |
646| no_control_alumno | int(11) | NO | UNI | null | |
647| semestre_alumno | int(11) | NO | | null | |
648| edad_alumno | int(11) | YES | | null | |
649| telefono_alumno | int(11) | YES | | null | |
650| correo_electr_alumno | varchar(50) | YES | | null | |
651| especilidad | varchar(50) | NO | | null | |
652+----------------------+-------------+------+-----+---------+-------+
65310 rows in set (0.00 sec)
654mysql-sql> alter table alumno change no_control_alumno no_control_alumno int not null;
655Query OK, 0 rows affected (0.19 sec)
656
657Records: 0 Duplicates: 0 Warnings: 0
658mysql-sql> alter table alumno add unique(no_control_alumno);
659Query OK, 0 rows affected, 1 warning (0.60 sec)
660
661Records: 0 Duplicates: 0 Warnings: 1
662Warning (code 1831): Duplicate index 'no_control_alumno_2' defined on the table 'ejercicios.alumno'. This is deprecated and will be disallowed in a future release.
663mysql-sql> show tables;
664+----------------------+
665| Tables_in_ejercicios |
666+----------------------+
667| alumno |
668| carrera |
669| copia_alumno |
670| docentes |
671| dup_alumno |
672| institutos |
673+----------------------+
6746 rows in set (0.00 sec)
675mysql-sql> alter table ciudadano add primary key(alumno_id);
676ERROR: 1146 (42S02): Table 'ejercicios.ciudadano' doesn't exist
677mysql-sql> alter table alumno add primary key(alumno_id);
678ERROR: 1068 (42000): Multiple primary key defined
679mysql-sql> alter table alumno change alumno_id alumno_id int not null auto_incremet;
680ERROR: 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 'auto_increme
681t' at line 1
682mysql-sql>
683mysql-sql> alter table alumno change alumno_id alumno_id int not null auto_increment;
684Query OK, 0 rows affected (1.80 sec)
685
686Records: 0 Duplicates: 0 Warnings: 0
687mysql-sql> desc carrera;
688+------------------+-------------+------+-----+---------+-------+
689| Field | Type | Null | Key | Default | Extra |
690+------------------+-------------+------+-----+---------+-------+
691| carrera_id | int(11) | NO | | null | |
692| nombre_carrera | varchar(50) | NO | | null | |
693| creditos_carrera | int(11) | NO | | null | |
694+------------------+-------------+------+-----+---------+-------+
6953 rows in set (0.00 sec)
696mysql-sql> alter table carrera add primary key(carrera_id);
697Query OK, 0 rows affected (1.10 sec)
698
699Records: 0 Duplicates: 0 Warnings: 0
700mysql-sql> alter table carrera change carrera_id carrera_id int not null auto_increment;
701Query OK, 0 rows affected (1.00 sec)
702
703Records: 0 Duplicates: 0 Warnings: 0
704mysql-sql> alter table carrrera change carrera_id carrera_id int not null;
705ERROR: 1146 (42S02): Table 'ejercicios.carrrera' doesn't exist
706mysql-sql> alter table carrera change carrera_id carrera_id int not null;
707Query OK, 0 rows affected (1.06 sec)
708
709Records: 0 Duplicates: 0 Warnings: 0
710mysql-sql> desc docentes;
711+----------------------+----------------------------------------------------------------------------------------------------------------------------------------+------+
712-----+---------+-------+
713| Field | Type | Null |
714 Key | Default | Extra |
715+----------------------+----------------------------------------------------------------------------------------------------------------------------------------+------+
716-----+---------+-------+
717| docentes_id | int(11) | NO |
718 | null | |
719| nombre_docente | varchar(50) | NO |
720 | null | |
721| ape_pat_docente | varchar(50) | NO |
722 | null | |
723| ape_mat_docente | varchar(50) | NO |
724 | null | |
725| horas_plaza | int(11) | NO |
726 | 8 | |
727| departamento_docente | enum('SISTEMAS Y COMPUTACION','INGENIERIA INDUSTRIAL','CIENCIAS DE LA TIERRA','CIENCIAS ECONOMICO ADMINISTRATIVAS','CIENCIAS BASICAS') | NO |
728 | null | |
729+----------------------+----------------------------------------------------------------------------------------------------------------------------------------+------+
730-----+---------+-------+
7316 rows in set (0.00 sec)
732mysql-sql> alter table docentes add primary key(docenets_id);
733ERROR: 1072 (42000): Key column 'docenets_id' doesn't exist in table
734mysql-sql> alter table docentes add primary key(docentes_id);
735Query OK, 0 rows affected (0.79 sec)
736
737Records: 0 Duplicates: 0 Warnings: 0
738mysql-sql> alter table docentes change docentes_id docentes_id int not null auto_increment;
739Query OK, 0 rows affected (0.97 sec)
740
741Records: 0 Duplicates: 0 Warnings: 0
742mysql-sql> alter table docentes change docentes_id docentes_id int not null;
743Query OK, 0 rows affected (1.28 sec)
744
745Records: 0 Duplicates: 0 Warnings: 0
746mysql-sql> desc institutos;
747+------------------+----------------------------------------------------------------------------------------------------------------------------------------------------
748------------------------------------------------------------------------------------------------------------------------------------------------------------------------
749-----------------------------------------------------------------------------+------+-----+---------+-------+
750| Field | Type
751
752 | Null | Key | Default | Extra |
753+------------------+----------------------------------------------------------------------------------------------------------------------------------------------------
754------------------------------------------------------------------------------------------------------------------------------------------------------------------------
755-----------------------------------------------------------------------------+------+-----+---------+-------+
756| instituto_id | int(11)
757
758 | YES | | null | |
759| nombre_instituto | varchar(50)
760
761 | YES | UNI | null | |
762| estado_instituto | enum('Aguascalientes','Baja california','Baja california sur','Campeche','Chiapas','Chihuahua','Ciudad de México','Coahuila','Colima','Durango','Gu
763anajuato','Guerrero','Hidalgo','Jalisco','México','Michoacán','Morelos','Nayarit','Nuevo león','Oaxaca','Puebla','Queretaro','Quintana roo','San Luis PotosÃ','Sinaloa',
764'Sonora','Tabasco','Tamaulipas','Tlaxcala','Veracruz','Yucatán','Zacatecas') | YES | | null | |
765+------------------+----------------------------------------------------------------------------------------------------------------------------------------------------
766------------------------------------------------------------------------------------------------------------------------------------------------------------------------
767-----------------------------------------------------------------------------+------+-----+---------+-------+
7683 rows in set (0.06 sec)
769mysql-sql> alter table institutos add primary key(instituto_id);
770Query OK, 0 rows affected (0.92 sec)
771
772Records: 0 Duplicates: 0 Warnings: 0
773mysql-sql> alter table institutos change institutp_id isntituto_id int not null;
774ERROR: 1054 (42S22): Unknown column 'institutp_id' in 'institutos'
775mysql-sql> alter table institutos change institutp_id instituto_id int not null;
776ERROR: 1054 (42S22): Unknown column 'institutp_id' in 'institutos'
777mysql-sql> alter table institutos change instituto_id instituto_id int not null;
778Query OK, 0 rows affected (0.09 sec)
779
780Records: 0 Duplicates: 0 Warnings: 0
781mysql-sql> alter table institutos change instituto_id instituto_id int not null auto_increment;
782Query OK, 0 rows affected (1.34 sec)
783
784Records: 0 Duplicates: 0 Warnings: 0
785mysql-sql> desc alumno;
786+----------------------+-------------+------+-----+---------+----------------+
787| Field | Type | Null | Key | Default | Extra |
788+----------------------+-------------+------+-----+---------+----------------+
789| alumno_id | int(11) | NO | PRI | null | auto_increment |
790| nombre_alumno | varchar(50) | NO | | null | |
791| apellido_pat_alumno | varchar(50) | NO | | null | |
792| apellido_mat_alumno | varchar(50) | NO | | null | |
793| no_control_alumno | int(11) | NO | UNI | null | |
794| semestre_alumno | int(11) | NO | | null | |
795| edad_alumno | int(11) | YES | | null | |
796| telefono_alumno | int(11) | YES | | null | |
797| correo_electr_alumno | varchar(50) | YES | | null | |
798| especilidad | varchar(50) | NO | | null | |
799+----------------------+-------------+------+-----+---------+----------------+
80010 rows in set (0.00 sec)
801mysql-sql> desc carrera:
802 ... ;
803ERROR: 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
804
805mysql-sql> desc carrera;
806+------------------+-------------+------+-----+---------+-------+
807| Field | Type | Null | Key | Default | Extra |
808+------------------+-------------+------+-----+---------+-------+
809| carrera_id | int(11) | NO | PRI | null | |
810| nombre_carrera | varchar(50) | NO | | null | |
811| creditos_carrera | int(11) | NO | | null | |
812+------------------+-------------+------+-----+---------+-------+
8133 rows in set (0.00 sec)
814mysql-sql> alter table carrera change carrera_id carrera_id int not null auto_increment;
815Query OK, 0 rows affected (1.08 sec)
816
817Records: 0 Duplicates: 0 Warnings: 0
818mysql-sql> desc carrera;
819+------------------+-------------+------+-----+---------+----------------+
820| Field | Type | Null | Key | Default | Extra |
821+------------------+-------------+------+-----+---------+----------------+
822| carrera_id | int(11) | NO | PRI | null | auto_increment |
823| nombre_carrera | varchar(50) | NO | | null | |
824| creditos_carrera | int(11) | NO | | null | |
825+------------------+-------------+------+-----+---------+----------------+
8263 rows in set (0.00 sec)
827mysql-sql> desc docentes;
828+----------------------+----------------------------------------------------------------------------------------------------------------------------------------+------+
829-----+---------+-------+
830| Field | Type | Null |
831 Key | Default | Extra |
832+----------------------+----------------------------------------------------------------------------------------------------------------------------------------+------+
833-----+---------+-------+
834| docentes_id | int(11) | NO |
835 PRI | null | |
836| nombre_docente | varchar(50) | NO |
837 | null | |
838| ape_pat_docente | varchar(50) | NO |
839 | null | |
840| ape_mat_docente | varchar(50) | NO |
841 | null | |
842| horas_plaza | int(11) | NO |
843 | 8 | |
844| departamento_docente | enum('SISTEMAS Y COMPUTACION','INGENIERIA INDUSTRIAL','CIENCIAS DE LA TIERRA','CIENCIAS ECONOMICO ADMINISTRATIVAS','CIENCIAS BASICAS') | NO |
845 | null | |
846+----------------------+----------------------------------------------------------------------------------------------------------------------------------------+------+
847-----+---------+-------+
8486 rows in set (0.00 sec)
849mysql-sql> desc institutos;
850+------------------+----------------------------------------------------------------------------------------------------------------------------------------------------
851------------------------------------------------------------------------------------------------------------------------------------------------------------------------
852-----------------------------------------------------------------------------+------+-----+---------+----------------+
853| Field | Type
854
855 | Null | Key | Default | Extra |
856+------------------+----------------------------------------------------------------------------------------------------------------------------------------------------
857------------------------------------------------------------------------------------------------------------------------------------------------------------------------
858-----------------------------------------------------------------------------+------+-----+---------+----------------+
859| instituto_id | int(11)
860
861 | NO | PRI | null | auto_increment |
862| nombre_instituto | varchar(50)
863
864 | YES | UNI | null | |
865| estado_instituto | enum('Aguascalientes','Baja california','Baja california sur','Campeche','Chiapas','Chihuahua','Ciudad de México','Coahuila','Colima','Durango','Gu
866anajuato','Guerrero','Hidalgo','Jalisco','México','Michoacán','Morelos','Nayarit','Nuevo león','Oaxaca','Puebla','Queretaro','Quintana roo','San Luis PotosÃ','Sinaloa',
867'Sonora','Tabasco','Tamaulipas','Tlaxcala','Veracruz','Yucatán','Zacatecas') | YES | | null | |
868+------------------+----------------------------------------------------------------------------------------------------------------------------------------------------
869------------------------------------------------------------------------------------------------------------------------------------------------------------------------
870-----------------------------------------------------------------------------+------+-----+---------+----------------+
8713 rows in set (0.02 sec)