0 évaluation0% ont trouvé ce document utile (0 vote)
392 vues9 pages
Your MySQL connection id is 3 server version: 5.1.42-community MySQL Community Server (GPL) type 'help;' or 'h' for help. Type 'c' to clear the current input statement.
Your MySQL connection id is 3 server version: 5.1.42-community MySQL Community Server (GPL) type 'help;' or 'h' for help. Type 'c' to clear the current input statement.
Your MySQL connection id is 3 server version: 5.1.42-community MySQL Community Server (GPL) type 'help;' or 'h' for help. Type 'c' to clear the current input statement.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3 Server version: 5.1.42-community MySQL Community Server (GPL) Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> create database tiendavideo; Query OK, 1 row affected (0.00 sec) mysql> use tiendavideo; Database changed mysql> create table clientes(id_clientes int primary key auto_increment, -> nombre varchar(30), direccion varchar(30), telefono int)type=innodb; Query OK, 0 rows affected, 1 warning (0.11 sec) mysql> create table empleados(id_empleados int primary key auto_increment, -> nombre varchar(30), direccion varchar(30), telefono int, -> sueldo int)type=innodb; Query OK, 0 rows affected, 1 warning (0.11 sec) mysql> Enter password: *** Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 5 Server version: 5.1.42-community MySQL Community Server (GPL) Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> use tiendavideo; Database changed mysql> create table productos(id_productos int primary key auto_increment, -> id_clientes int, precio int, garantia int, nombre varchar(30), -> foreing key(id_clientes) references clientes(id_clientes), on delete casc ade on update cascade)type=innodb; 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 'key(i d_clientes) references clientes(id_clientes), on delete cascade on update c' at line 3 mysql> create table productos(id_productos int primary key auto_increment, -> nombre varchar(30), precio int, garantia int)type=innodb; Query OK, 0 rows affected, 1 warning (0.11 sec) mysql> show tables; +-----------------------+ | Tables_in_tiendavideo | +-----------------------+ | clientes | | empleados | | productos | | proveedor | +-----------------------+ 4 rows in set (0.00 sec) mysql> create table ventas(id_ventas int primary key auto_increment, -> id_clientes int, -> id_empleados int, -> fecha date, -> total double, -> foreign key(id_clientes) references clientes(id_clientes), -> foreign key(id_empleados) references empleados(id_empleados) on delete ca scade on update cascade)type=innodb; Query OK, 0 rows affected, 1 warning (0.41 sec) mysql> create table compras(id_compras int primary key auto_increment, -> id_proveedor int, id_empleados int, -> fecha date, cantidad int, total double, -> foreing key(id_proveedor) references proveedor(id_proveedor), -> foreing key(id_empleados) references empleados(id_empleados) on delete ca scade on update cascade)type=innodb; 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 'key(i d_proveedor) references proveedor(id_proveedor), foreing key(id_empleados) ' at line 4 mysql> create table compras(id_compras int primary key auto_increment, -> id_proveedor int, id_empleados int, -> fecha date, cantidad int, total double, -> foreing key(id_proveedor) references proveedor(id_proveedor), -> foreign key(id_empleados) references empleados(id_empleados) on delete ca scade on update cascade)type=innodb; 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 'key(i d_proveedor) references proveedor(id_proveedor), foreign key(id_empleados) ' at line 4 mysql> create table ventas(id_ventas int primary key auto_increment, -> foreing key(id_clientes) references clientes(id_clientes), on delete casc ade on update cascade)type=innodb;; 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 'key(i d_clientes) references clientes(id_clientes), on delete cascade on update c' at line 2 ERROR: No query specified mysql> create table compras(id_compras int primary key auto_increment, -> id_proveedor int, id_empleados int, -> fecha date, cantidad int, total double, -> foreign key(id_proveedor) references proveedor(id_proveedor)on delete cas cade on update, -> foreign key(id_empleados) references empleados(id_empleados) on delete ca scade on update cascade)type=innodb; 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 ' foreign key(id_empleados) references empleados(id_empleados) on delete cascade ' at line 4 mysql> create table compras(id_compras int primary key auto_increment, -> id_proveedor int, id_empleados int, fecha date, cantidad int, total doubl e, foreign key(id_proveedor) references proveedor(id_proveedor) on delete cascad e on update cascade, foreign key(id_empleados) references empleados(id_empleados ) on delete cascade on update cascade)type=innodb; Query OK, 0 rows affected, 1 warning (0.39 sec) mysql> create table det_ventas(id_det_ventas int primary key auto_increment, -> id_productos int, id_ventas int, cantidad int, subtotal double, foreign k ey(id_productos) references productos(id_productos) on delete cascade on update cascade, foreign key(id_ventas) references ventas(id_ventas) on delete cascade o n update cascade)type=innodb; Query OK, 0 rows affected, 1 warning (0.16 sec) mysql> create table det_compras(id_compras int primary key auto_increment, -> id_productos int, id_compras int, cantidad int, subtotal double, foreign key(id_productos) references productos(id_productos) on delete cascade on update cascade, foreign key(id_compras) references compras(id_compras) on delete casca de on update cascade)type=innodb; ERROR 1060 (42S21): Duplicate column name 'id_compras' mysql> create table det_compras(id_det_compras int primary key auto_increment, -> id_productos int, id_det_compras int, cantidad int, subtotal double, fore ign key(id_productos) references productos(id_productos) on delete cascade on up date cascade, foreign key(id_compras) references compras(id_compras) on delete c ascade on update cascade)type=innodb; ERROR 1060 (42S21): Duplicate column name 'id_det_compras' mysql> show tables; +-----------------------+ | Tables_in_tiendavideo | +-----------------------+ | clientes | | compras | | det_ventas | | empleados | | productos | | proveedor | | ventas | +-----------------------+ 7 rows in set (0.00 sec) mysql> create table det_compras(id_det_compras int primary key auto_increment, -> id_compras int, id_productos int, cantidad int, subtotal double, foreign key(id_compras) references compras(id_compras) on delete cascade on update casc ade, foreign key(id_productos) references productos(id_productos) on delete casc ade on update cascade)type=innodb; Query OK, 0 rows affected, 1 warning (0.16 sec) mysql> show tables; +-----------------------+ | Tables_in_tiendavideo | +-----------------------+ | clientes | | compras | | det_compras | | det_ventas | | empleados | | productos | | proveedor | | ventas | +-----------------------+ 8 rows in set (0.01 sec) mysql> describe clientes; +-------------+-------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +-------------+-------------+------+-----+---------+----------------+ | id_clientes | int(11) | NO | PRI | NULL | auto_increment | | nombre | varchar(30) | YES | | NULL | | | direccion | varchar(30) | YES | | NULL | | | telefono | int(11) | YES | | NULL | | +-------------+-------------+------+-----+---------+----------------+ 4 rows in set (0.00 sec) mysql> inser into clientes values(null,"Diego", "Medina Ascensio",7830383); 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 'inser into clientes values(null,"Diego", "Medina Ascensio",7830383)' at line 1 mysql> insert into clientes values(null,"Diego", "Medina Ascensio",7830383); Query OK, 1 row affected (0.31 sec) mysql> insert into clientes values(null,"Raul", "General Arteaga",7845613); Query OK, 1 row affected (0.06 sec) mysql> describe productos; +--------------+-------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +--------------+-------------+------+-----+---------+----------------+ | id_productos | int(11) | NO | PRI | NULL | auto_increment | | nombre | varchar(30) | YES | | NULL | | | precio | int(11) | YES | | NULL | | | garantia | int(11) | YES | | NULL | | +--------------+-------------+------+-----+---------+----------------+ 4 rows in set (0.02 sec) mysql> insert into productos values(null, "Fifa 14", 500, 1); Query OK, 1 row affected (0.06 sec) mysql> insert into productos values(null, "GTAV", 700, 2); Query OK, 1 row affected (0.06 sec) mysql> describe proveedor; +--------------+-------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +--------------+-------------+------+-----+---------+----------------+ | id_proveedor | int(11) | NO | PRI | NULL | auto_increment | | nombre | varchar(30) | YES | | NULL | | | direccion | varchar(30) | YES | | NULL | | | telefono | int(11) | YES | | NULL | | | ciudad | varchar(30) | YES | | NULL | | | marca | varchar(30) | YES | | NULL | | +--------------+-------------+------+-----+---------+----------------+ 6 rows in set (0.00 sec) mysql> insert into proveedor values(null, "Alejandro", "Santa Monica", 348100201 4, "ayotlan", "Xbox 360, Play Station 3"); ERROR 1264 (22003): Out of range value for column 'telefono' at row 1 mysql> insert into proveedor values(null, "Alejandro", "Santa Monica",3481002014 , "ayotlan","Xbox 360, Play Station 3"); ERROR 1264 (22003): Out of range value for column 'telefono' at row 1 mysql> insert into proveedor values(null, "Alejandro", "Santa Monica",3481002014 , "ayotlan","Xbox 360"); ERROR 1264 (22003): Out of range value for column 'telefono' at row 1 mysql> insert into proveedor values(1,"Alejandro","Santa Monica",3481002014,"ayo tlan","Xbox 360, Play Station 3"); ERROR 1264 (22003): Out of range value for column 'telefono' at row 1 mysql> insert into proveedor values(1,"Alejandro","Santa Monica",7043044,"ayotla n","Xbox 360, Play Station 3"); Query OK, 1 row affected (0.06 sec) mysql> insert into proveedor values(2,"Raul","Javier mina",7839060,"guadalajara" ,"Xbox 360, Play Station 3"); Query OK, 1 row affected (0.30 sec) mysql> Enter password: *** Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 5 Server version: 5.1.42-community MySQL Community Server (GPL) Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> use tiendavideo; Database changed mysql> create table productos(id_productos int primary key auto_increment, -> id_clientes int, precio int, garantia int, nombre varchar(30), -> foreing key(id_clientes) references clientes(id_clientes), on delete casc ade on update cascade)type=innodb; 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 'key(i d_clientes) references clientes(id_clientes), on delete cascade on update c' at line 3 mysql> create table productos(id_productos int primary key auto_increment, -> nombre varchar(30), precio int, garantia int)type=innodb; Query OK, 0 rows affected, 1 warning (0.11 sec) mysql> show tables; +-----------------------+ | Tables_in_tiendavideo | +-----------------------+ | clientes | | empleados | | productos | | proveedor | +-----------------------+ 4 rows in set (0.00 sec) mysql> create table ventas(id_ventas int primary key auto_increment, -> id_clientes int, -> id_empleados int, -> fecha date, -> total double, -> foreign key(id_clientes) references clientes(id_clientes), -> foreign key(id_empleados) references empleados(id_empleados) on delete ca scade on update cascade)type=innodb; Query OK, 0 rows affected, 1 warning (0.41 sec) mysql> create table compras(id_compras int primary key auto_increment, -> id_proveedor int, id_empleados int, -> fecha date, cantidad int, total double, -> foreing key(id_proveedor) references proveedor(id_proveedor), -> foreing key(id_empleados) references empleados(id_empleados) on delete ca scade on update cascade)type=innodb; 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 'key(i d_proveedor) references proveedor(id_proveedor), foreing key(id_empleados) ' at line 4 mysql> create table compras(id_compras int primary key auto_increment, -> id_proveedor int, id_empleados int, -> fecha date, cantidad int, total double, -> foreing key(id_proveedor) references proveedor(id_proveedor), -> foreign key(id_empleados) references empleados(id_empleados) on delete ca scade on update cascade)type=innodb; 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 'key(i d_proveedor) references proveedor(id_proveedor), foreign key(id_empleados) ' at line 4 mysql> create table ventas(id_ventas int primary key auto_increment, -> foreing key(id_clientes) references clientes(id_clientes), on delete casc ade on update cascade)type=innodb;; 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 'key(i d_clientes) references clientes(id_clientes), on delete cascade on update c' at line 2 ERROR: No query specified mysql> create table compras(id_compras int primary key auto_increment, -> id_proveedor int, id_empleados int, -> fecha date, cantidad int, total double, -> foreign key(id_proveedor) references proveedor(id_proveedor)on delete cas cade on update, -> foreign key(id_empleados) references empleados(id_empleados) on delete ca scade on update cascade)type=innodb; 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 ' foreign key(id_empleados) references empleados(id_empleados) on delete cascade ' at line 4 mysql> create table compras(id_compras int primary key auto_increment, -> id_proveedor int, id_empleados int, fecha date, cantidad int, total doubl e, foreign key(id_proveedor) references proveedor(id_proveedor) on delete cascad e on update cascade, foreign key(id_empleados) references empleados(id_empleados ) on delete cascade on update cascade)type=innodb; Query OK, 0 rows affected, 1 warning (0.39 sec) mysql> create table det_ventas(id_det_ventas int primary key auto_increment, -> id_productos int, id_ventas int, cantidad int, subtotal double, foreign k ey(id_productos) references productos(id_productos) on delete cascade on update cascade, foreign key(id_ventas) references ventas(id_ventas) on delete cascade o n update cascade)type=innodb; Query OK, 0 rows affected, 1 warning (0.16 sec) mysql> create table det_compras(id_compras int primary key auto_increment, -> id_productos int, id_compras int, cantidad int, subtotal double, foreign key(id_productos) references productos(id_productos) on delete cascade on update cascade, foreign key(id_compras) references compras(id_compras) on delete casca de on update cascade)type=innodb; ERROR 1060 (42S21): Duplicate column name 'id_compras' mysql> create table det_compras(id_det_compras int primary key auto_increment, -> id_productos int, id_det_compras int, cantidad int, subtotal double, fore ign key(id_productos) references productos(id_productos) on delete cascade on up date cascade, foreign key(id_compras) references compras(id_compras) on delete c ascade on update cascade)type=innodb; ERROR 1060 (42S21): Duplicate column name 'id_det_compras' mysql> show tables; +-----------------------+ | Tables_in_tiendavideo | +-----------------------+ | clientes | | compras | | det_ventas | | empleados | | productos | | proveedor | | ventas | +-----------------------+ 7 rows in set (0.00 sec) mysql> create table det_compras(id_det_compras int primary key auto_increment, -> id_compras int, id_productos int, cantidad int, subtotal double, foreign key(id_compras) references compras(id_compras) on delete cascade on update casc ade, foreign key(id_productos) references productos(id_productos) on delete casc ade on update cascade)type=innodb; Query OK, 0 rows affected, 1 warning (0.16 sec) mysql> show tables; +-----------------------+ | Tables_in_tiendavideo | +-----------------------+ | clientes | | compras | | det_compras | | det_ventas | | empleados | | productos | | proveedor | | ventas | +-----------------------+ 8 rows in set (0.01 sec) mysql> describe clientes; +-------------+-------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +-------------+-------------+------+-----+---------+----------------+ | id_clientes | int(11) | NO | PRI | NULL | auto_increment | | nombre | varchar(30) | YES | | NULL | | | direccion | varchar(30) | YES | | NULL | | | telefono | int(11) | YES | | NULL | | +-------------+-------------+------+-----+---------+----------------+ 4 rows in set (0.00 sec) mysql> inser into clientes values(null,"Diego", "Medina Ascensio",7830383); 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 'inser into clientes values(null,"Diego", "Medina Ascensio",7830383)' at line 1 mysql> insert into clientes values(null,"Diego", "Medina Ascensio",7830383); Query OK, 1 row affected (0.31 sec) mysql> insert into clientes values(null,"Raul", "General Arteaga",7845613); Query OK, 1 row affected (0.06 sec) mysql> describe productos; +--------------+-------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +--------------+-------------+------+-----+---------+----------------+ | id_productos | int(11) | NO | PRI | NULL | auto_increment | | nombre | varchar(30) | YES | | NULL | | | precio | int(11) | YES | | NULL | | | garantia | int(11) | YES | | NULL | | +--------------+-------------+------+-----+---------+----------------+ 4 rows in set (0.02 sec) mysql> insert into productos values(null, "Fifa 14", 500, 1); Query OK, 1 row affected (0.06 sec) mysql> insert into productos values(null, "GTAV", 700, 2); Query OK, 1 row affected (0.06 sec) mysql> describe proveedor; +--------------+-------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +--------------+-------------+------+-----+---------+----------------+ | id_proveedor | int(11) | NO | PRI | NULL | auto_increment | | nombre | varchar(30) | YES | | NULL | | | direccion | varchar(30) | YES | | NULL | | | telefono | int(11) | YES | | NULL | | | ciudad | varchar(30) | YES | | NULL | | | marca | varchar(30) | YES | | NULL | | +--------------+-------------+------+-----+---------+----------------+ 6 rows in set (0.00 sec) mysql> insert into proveedor values(null, "Alejandro", "Santa Monica", 348100201 4, "ayotlan", "Xbox 360, Play Station 3"); ERROR 1264 (22003): Out of range value for column 'telefono' at row 1 mysql> insert into proveedor values(null, "Alejandro", "Santa Monica",3481002014 , "ayotlan","Xbox 360, Play Station 3"); ERROR 1264 (22003): Out of range value for column 'telefono' at row 1 mysql> insert into proveedor values(null, "Alejandro", "Santa Monica",3481002014 , "ayotlan","Xbox 360"); ERROR 1264 (22003): Out of range value for column 'telefono' at row 1 mysql> insert into proveedor values(1,"Alejandro","Santa Monica",3481002014,"ayo tlan","Xbox 360, Play Station 3"); ERROR 1264 (22003): Out of range value for column 'telefono' at row 1 mysql> insert into proveedor values(1,"Alejandro","Santa Monica",7043044,"ayotla n","Xbox 360, Play Station 3"); Query OK, 1 row affected (0.06 sec) mysql> insert into proveedor values(2,"Raul","Javier mina",7839060,"guadalajara" ,"Xbox 360, Play Station 3"); Query OK, 1 row affected (0.30 sec) mysql> describe empleados; +--------------+-------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +--------------+-------------+------+-----+---------+----------------+ | id_empleados | int(11) | NO | PRI | NULL | auto_increment | | nombre | varchar(30) | YES | | NULL | | | direccion | varchar(30) | YES | | NULL | | | telefono | int(11) | YES | | NULL | | | sueldo | int(11) | YES | | NULL | | +--------------+-------------+------+-----+---------+----------------+ 5 rows in set (0.01 sec) mysql> insert into empleados values(1,"Luis", "Guillermo prieto", 7814327, 700); Query OK, 1 row affected (0.31 sec) mysql> insert into empleados values(2,"Angel", "Constituyentes", 7832794, 800); Query OK, 1 row affected (0.31 sec) mysql> describe ventas; +--------------+---------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +--------------+---------+------+-----+---------+----------------+ | id_ventas | int(11) | NO | PRI | NULL | auto_increment | | id_clientes | int(11) | YES | MUL | NULL | | | id_empleados | int(11) | YES | MUL | NULL | | | fecha | date | YES | | NULL | | | total | double | YES | | NULL | | +--------------+---------+------+-----+---------+----------------+ 5 rows in set (0.00 sec) mysql> drop table ventas; ERROR 1217 (23000): Cannot delete or update a parent row: a foreign key constrai nt fails mysql> drop table ventas; ERROR 1217 (23000): Cannot delete or update a parent row: a foreign key constrai nt fails mysql> drop tables ventas; ERROR 1217 (23000): Cannot delete or update a parent row: a foreign key constrai nt fails mysql> describe ventas; +--------------+---------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +--------------+---------+------+-----+---------+----------------+ | id_ventas | int(11) | NO | PRI | NULL | auto_increment | | id_clientes | int(11) | YES | MUL | NULL | | | id_empleados | int(11) | YES | MUL | NULL | | | fecha | date | YES | | NULL | | | total | double | YES | | NULL | | +--------------+---------+------+-----+---------+----------------+ 5 rows in set (0.00 sec) mysql>