mysql> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | automoviles | | biblioteca | | cdcol | | factura | | libreria | | mysql | | performance_schema | | phpmyadmin | | test | | webauth | +--------------------+ 11 rows in set (0.00 sec) mysql> use factura; Database changed mysql> show tables; Empty set (0.00 sec) mysql> create table producto -> (id producto char(10) not null primary key, -> nombre_producto char (40) not null, -> precio_unitario int (10) not null); 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 'producto char(10) not null primary key, nombre_producto char (40) not null, prec' at line 2 mysql> create table producto -> (id_producto char (10) not null primary key, -> nombre_producto char (40) not null, -> precio_unitario int (10) not null); Query OK, 0 rows affected (0.57 sec) mysql> create table pedido -> (id_pedido char(10) not null primary key, -> id_cliente char(10) not null, -> nombre_cliente char(10) not null, -> direccion char(40) not null, -> telefono char(10) not null); Query OK, 0 rows affected (0.31 sec) mysql> describe table producto; 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 'table producto' at line 1 mysql> describe producto; +-----------------+----------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +-----------------+----------+------+-----+---------+-------+ | id_producto | char(10) | NO | PRI | NULL | | | nombre_producto | char(40) | NO | | NULL | | | precio_unitario | int(10) | NO | | NULL | | +-----------------+----------+------+-----+---------+-------+ 3 rows in set (0.17 sec) mysql> describe pedido; +----------------+----------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +----------------+----------+------+-----+---------+-------+ | id_pedido | char(10) | NO | PRI | NULL | | | id_cliente | char(10) | NO | | NULL | | | nombre_cliente | char(10) | NO | | NULL | | | direccion | char(40) | NO | | NULL | | | telefono | char(10) | NO | | NULL | | +----------------+----------+------+-----+---------+-------+ 5 rows in set (0.13 sec) mysql> alter table pedido add email char(60) not null; Query OK, 0 rows affected (0.90 sec) Records: 0 Duplicates: 0 Warnings: 0 mysql> describe pedido; +----------------+----------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +----------------+----------+------+-----+---------+-------+ | id_pedido | char(10) | NO | PRI | NULL | | | id_cliente | char(10) | NO | | NULL | | | nombre_cliente | char(10) | NO | | NULL | | | direccion | char(40) | NO | | NULL | | | telefono | char(10) | NO | | NULL | | | email | char(60) | NO | | NULL | | +----------------+----------+------+-----+---------+-------+ 6 rows in set (0.07 sec) mysql> alter table pedido drop telefono; Query OK, 0 rows affected (0.53 sec) Records: 0 Duplicates: 0 Warnings: 0 mysql> describe pedido; +----------------+----------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +----------------+----------+------+-----+---------+-------+ | id_pedido | char(10) | NO | PRI | NULL | | | id_cliente | char(10) | NO | | NULL | | | nombre_cliente | char(10) | NO | | NULL | | | direccion | char(40) | NO | | NULL | | | email | char(60) | NO | | NULL | | +----------------+----------+------+-----+---------+-------+ 5 rows in set (0.03 sec) mysql> alter table producto modify email char (50) not null; ERROR 1054 (42S22): Unknown column 'email' in 'producto' mysql> alter table pedido modify email char (50) not null; Query OK, 0 rows affected (0.68 sec) Records: 0 Duplicates: 0 Warnings: 0 mysql> describe pedido; +----------------+----------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +----------------+----------+------+-----+---------+-------+ | id_pedido | char(10) | NO | PRI | NULL | | | id_cliente | char(10) | NO | | NULL | | | nombre_cliente | char(10) | NO | | NULL | | | direccion | char(40) | NO | | NULL | | | email | char(50) | NO | | NULL | | +----------------+----------+------+-----+---------+-------+ 5 rows in set (0.05 sec) mysql> alter table pedido modify id_cliente char (10) not null primary key; ERROR 1068 (42000): Multiple primary key defined mysql> alter table producto rename to PRODUCTO; Query OK, 0 rows affected (0.00 sec) mysql> alter table pedido rename to PEDIDO; Query OK, 0 rows affected (0.00 sec) mysql> describe PEDIDO; +----------------+----------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +----------------+----------+------+-----+---------+-------+ | id_pedido | char(10) | NO | PRI | NULL | | | id_cliente | char(10) | NO | | NULL | | | nombre_cliente | char(10) | NO | | NULL | | | direccion | char(40) | NO | | NULL | | | email | char(50) | NO | | NULL | | +----------------+----------+------+-----+---------+-------+ 5 rows in set (0.05 sec) mysql> create table Detalle -> (id_producto char(10) not null, -> id_pedido char (10) not null, -> cantidad int (7) not null, -> valor_total int (10) not null, -> foreign key(id_producto) references PRODUCTO(id_producto) on delete cascade on update cascade, -> foreign key(id_pedido) references PEDIDO(id_pedido) on delete cascade on update cascade); Query OK, 0 rows affected (0.31 sec) mysql> describe Detalle; +-------------+----------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +-------------+----------+------+-----+---------+-------+ | id_producto | char(10) | NO | MUL | NULL | | | id_pedido | char(10) | NO | MUL | NULL | | | cantidad | int(7) | NO | | NULL | | | valor_total | int(10) | NO | | NULL | | +-------------+----------+------+-----+---------+-------+ 4 rows in set (0.08 sec) mysql> describe PRODUCTO; +-----------------+----------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +-----------------+----------+------+-----+---------+-------+ | id_producto | char(10) | NO | PRI | NULL | | | nombre_producto | char(40) | NO | | NULL | | | precio_unitario | int(10) | NO | | NULL | | +-----------------+----------+------+-----+---------+-------+ 3 rows in set (0.05 sec) mysql> insert into PRODUCTO (id_producto,nombre_producto, precio_unitario) values ('001','caja primaria',80000); Query OK, 1 row affected (0.05 sec) mysql> insert into PRODUCTO (id_producto,nombre_producto, precio_unitario) values ('002','aislador',30000); Query OK, 1 row affected (0.02 sec) mysql> describe PEDIDO; +----------------+----------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +----------------+----------+------+-----+---------+-------+ | id_pedido | char(10) | NO | PRI | NULL | | | id_cliente | char(10) | NO | | NULL | | | nombre_cliente | char(10) | NO | | NULL | | | direccion | char(40) | NO | | NULL | | | email | char(50) | NO | | NULL | | +----------------+----------+------+-----+---------+-------+ 5 rows in set (0.06 sec) mysql> inser into PEDIDO (id_pedido,id_cliente,nombre_cliente,direccion,email) values ('001','001','Maria Josefina de las nieves','cra 70- 16 sur','josenieves@gmail.com'); 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 PEDIDO (id_pedido,id_cliente,nombre_cliente,direccion,email) values (' at line 1 mysql> insert into PEDIDO (id_pedido,id_cliente,nombre_cliente,direccion,email) values('000','001','josefina de las nieves','cr 56 n 33-23 sur','josenieves@gmail.com'); Query OK, 1 row affected, 1 warning (0.03 sec) mysql> select max (precio_unitario) from PRODUCTO; ERROR 1630 (42000): FUNCTION factura.max does not exist. Check the 'Function Name Parsing and Resolution' section in the Reference Manual mysql> select from * PRODUCTO; 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 'from * PRODUCTO' at line 1 mysql> select * from PRODUCTO; +-------------+-----------------+-----------------+ | id_producto | nombre_producto | precio_unitario | +-------------+-----------------+-----------------+ | 001 | caja primaria | 80000 | | 002 | aislador | 30000 | +-------------+-----------------+-----------------+ 2 rows in set (0.00 sec) mysql> select max(precio_unitario) from PRODUCTO; +----------------------+ | max(precio_unitario) | +----------------------+ | 80000 | +----------------------+ 1 row in set (0.03 sec) mysql> select * from PEDIDO order by nombre_producto; ERROR 1054 (42S22): Unknown column 'nombre_producto' in 'order clause' mysql> select * from PRODUCTO order by nombre_producto; +-------------+-----------------+-----------------+ | id_producto | nombre_producto | precio_unitario | +-------------+-----------------+-----------------+ | 002 | aislador | 30000 | | 001 | caja primaria | 80000 | +-------------+-----------------+-----------------+ 2 rows in set (0.02 sec) mysql> select * from PRODUCTO order by precio_unitario ; +-------------+-----------------+-----------------+ | id_producto | nombre_producto | precio_unitario | +-------------+-----------------+-----------------+ | 002 | aislador | 30000 | | 001 | caja primaria | 80000 | +-------------+-----------------+-----------------+ 2 rows in set (0.00 sec) mysql> select * from PRODUCTO order by precio_unitario desc; +-------------+-----------------+-----------------+ | id_producto | nombre_producto | precio_unitario | +-------------+-----------------+-----------------+ | 001 | caja primaria | 80000 | | 002 | aislador | 30000 | +-------------+-----------------+-----------------+ 2 rows in set (0.00 sec) mysql> exit