MariaDB [libreria]> create table libro -> (idlibro; ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '' at line 2 MariaDB [libreria]> create table materia -> (codigomat varchar(20) not null primary key, -> nombre varchar(60) not null); Query OK, 0 rows affected (0.375 sec) MariaDB [libreria]> create table libro -> (idlibro varchar(20) not null primary key, -> titulo varchar(60) not null, -> nropagina int not null, -> precio int not null, -> codigomat varchar(20) not null, -> foreign key (codigomat) references materia(codigomat) ON DELETE CASCADE ON UPDATE CASCADE); Query OK, 0 rows affected (0.452 sec) MariaDB [libreria]> describe libro -> ; +-----------+-------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +-----------+-------------+------+-----+---------+-------+ | idlibro | varchar(20) | NO | PRI | NULL | | | titulo | varchar(60) | NO | | NULL | | | nropagina | int(11) | NO | | NULL | | | precio | int(11) | NO | | NULL | | | codigomat | varchar(20) | NO | MUL | NULL | | +-----------+-------------+------+-----+---------+-------+ 5 rows in set (0.008 sec) MariaDB [libreria]> create describe libro; ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'describe libro' at line 1 MariaDB [libreria]> show create table libro -> ; +-------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | Table | Create Table | +-------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | libro | CREATE TABLE `libro` ( `idlibro` varchar(20) NOT NULL, `titulo` varchar(60) NOT NULL, `nropagina` int(11) NOT NULL, `precio` int(11) NOT NULL, `codigomat` varchar(20) NOT NULL, PRIMARY KEY (`idlibro`), KEY `codigomat` (`codigomat`), CONSTRAINT `libro_ibfk_1` FOREIGN KEY (`codigomat`) REFERENCES `materia` (`codigomat`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci | +-------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ 1 row in set (0.001 sec) MariaDB [libreria]> show tables; +--------------------+ | Tables_in_libreria | +--------------------+ | libro | | materia | +--------------------+ 2 rows in set (0.002 sec) MariaDB [libreria]> create table autor -> (codautor varchar(20) not null, -> nombre varchar(60) not null); Query OK, 0 rows affected (0.320 sec) MariaDB [libreria]> create table editorial -> (codedit varchar(20) not null primary key, -> nombre varchar(60) not null); Query OK, 0 rows affected (0.321 sec) MariaDB [libreria]> alter table autor change codautor Codautor varchar(20) not null primary key; Query OK, 0 rows affected (0.678 sec) Records: 0 Duplicates: 0 Warnings: 0 MariaDB [libreria]> describe autor; +----------+-------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +----------+-------------+------+-----+---------+-------+ | Codautor | varchar(20) | NO | PRI | NULL | | | nombre | varchar(60) | NO | | NULL | | +----------+-------------+------+-----+---------+-------+ 2 rows in set (0.009 sec) MariaDB [libreria]> describe editorial; +---------+-------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +---------+-------------+------+-----+---------+-------+ | codedit | varchar(20) | NO | PRI | NULL | | | nombre | varchar(60) | NO | | NULL | | +---------+-------------+------+-----+---------+-------+ 2 rows in set (0.009 sec) MariaDB [libreria]> create table liautedi -> (idlibro varchar(20) not null, -> codautor varchar(20) not null, -> codedit varchar(20) not null, -> foreign key (idlibro) references libro(idlibro) ON DELETE CASCADE ON UPDATE CASCADE, -> foreign key (codautor) references autor(codautor) ON DELETE CASCADE ON UPDATE CASCADE, -> foreign key (codedit) references editorial(codedit) ON DELETE CASCADE ON UPDATE CASCADE); Query OK, 0 rows affected (0.370 sec) MariaDB [libreria]> show create table liautedi; +----------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | Table | Create Table | +----------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | liautedi | CREATE TABLE `liautedi` ( `idlibro` varchar(20) NOT NULL, `codautor` varchar(20) NOT NULL, `codedit` varchar(20) NOT NULL, KEY `idlibro` (`idlibro`), KEY `codautor` (`codautor`), KEY `codedit` (`codedit`), CONSTRAINT `liautedi_ibfk_1` FOREIGN KEY (`idlibro`) REFERENCES `libro` (`idlibro`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `liautedi_ibfk_2` FOREIGN KEY (`codautor`) REFERENCES `autor` (`Codautor`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `liautedi_ibfk_3` FOREIGN KEY (`codedit`) REFERENCES `editorial` (`codedit`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci | +----------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ 1 row in set (0.002 sec) MariaDB [libreria]> show tables -> ; +--------------------+ | Tables_in_libreria | +--------------------+ | autor | | editorial | | liautedi | | libro | | materia | +--------------------+ 5 rows in set (0.002 sec) MariaDB [libreria]> SHOW CREATE TABLE libro; +-------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | Table | Create Table | +-------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | libro | CREATE TABLE `libro` ( `idlibro` varchar(20) NOT NULL, `titulo` varchar(60) NOT NULL, `nropagina` int(11) NOT NULL, `precio` int(11) NOT NULL, `codigomat` varchar(20) NOT NULL, PRIMARY KEY (`idlibro`), KEY `codigomat` (`codigomat`), CONSTRAINT `libro_ibfk_1` FOREIGN KEY (`codigomat`) REFERENCES `materia` (`codigomat`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci | +-------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ 1 row in set (0.001 sec) MariaDB [libreria]> SHOW CREATE TABLE autor; +-------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | Table | Create Table | +-------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | autor | CREATE TABLE `autor` ( `Codautor` varchar(20) NOT NULL, `nombre` varchar(60) NOT NULL, PRIMARY KEY (`Codautor`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci | +-------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ 1 row in set (0.000 sec) MariaDB [libreria]> SHOW CREATE TABLE editorial; +-----------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | Table | Create Table | +-----------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | editorial | CREATE TABLE `editorial` ( `codedit` varchar(20) NOT NULL, `nombre` varchar(60) NOT NULL, PRIMARY KEY (`codedit`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci | +-----------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ 1 row in set (0.000 sec) MariaDB [libreria]> SHOW CREATE TABLE libro; +-------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | Table | Create Table | +-------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | libro | CREATE TABLE `libro` ( `idlibro` varchar(20) NOT NULL, `titulo` varchar(60) NOT NULL, `nropagina` int(11) NOT NULL, `precio` int(11) NOT NULL, `codigomat` varchar(20) NOT NULL, PRIMARY KEY (`idlibro`), KEY `codigomat` (`codigomat`), CONSTRAINT `libro_ibfk_1` FOREIGN KEY (`codigomat`) REFERENCES `materia` (`codigomat`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci | +-------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ 1 row in set (0.001 sec) MariaDB [libreria]> SHOW CREATE TABLE autor; +-------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | Table | Create Table | +-------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | autor | CREATE TABLE `autor` ( `Codautor` varchar(20) NOT NULL, `nombre` varchar(60) NOT NULL, PRIMARY KEY (`Codautor`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci | +-------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ 1 row in set (0.000 sec) MariaDB [libreria]> SHOW CREATE TABLE editorial; +-----------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | Table | Create Table | +-----------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | editorial | CREATE TABLE `editorial` ( `codedit` varchar(20) NOT NULL, `nombre` varchar(60) NOT NULL, PRIMARY KEY (`codedit`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci | +-----------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ 1 row in set (0.000 sec) MariaDB [libreria]> show create liautedi; ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'liautedi' at line 1 MariaDB [libreria]> show create table liautedi; +----------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | Table | Create Table | +----------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | liautedi | CREATE TABLE `liautedi` ( `idlibro` varchar(20) NOT NULL, `codautor` varchar(20) NOT NULL, `codedit` varchar(20) NOT NULL, KEY `idlibro` (`idlibro`), KEY `codautor` (`codautor`), KEY `codedit` (`codedit`), CONSTRAINT `liautedi_ibfk_1` FOREIGN KEY (`idlibro`) REFERENCES `libro` (`idlibro`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `liautedi_ibfk_2` FOREIGN KEY (`codautor`) REFERENCES `autor` (`Codautor`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `liautedi_ibfk_3` FOREIGN KEY (`codedit`) REFERENCES `editorial` (`codedit`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci | +----------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ 1 row in set (0.001 sec) MariaDB [libreria]> | libro | CREATE TABLE `libro` ( -> `idlibro` varchar(20) NOT NULL, -> `titulo` varchar(60) NOT NULL, -> `nropagina` int(11) NOT NULL, -> `precio` int(11) NOT NULL, -> `codigomat` varchar(20) NOT NULL, -> PRIMARY KEY (`idlibro`), -> KEY `codigomat` (`codigomat`), -> CONSTRAINT `libro_ibfk_1` FOREIGN KEY (`codigomat`) REFERENCES `materia` (`codigomat`) ON DELETE CASCADE ON UPDATE CASCADE -> ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci | -> +-------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -> 1 row in set (0.001 sec) -> -> MariaDB [libreria]> SHOW CREATE TABLE autor; ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '| libro | CREATE TABLE `libro` ( `idlibro` varchar(20) NOT NULL, `titulo`...' at line 1 MariaDB [libreria]> +-------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -> | Table | Create Table | -> +-------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -> | autor | CREATE TABLE `autor` ( -> `Codautor` varchar(20) NOT NULL, -> `nombre` varchar(60) NOT NULL, -> PRIMARY KEY (`Codautor`) -> ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci | -> +-------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -> 1 row in set (0.000 sec) -> -> MariaDB [libreria]> SHOW CREATE TABLE editorial; ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '+-------+--------------------------------------------------------------------...' at line 1 MariaDB [libreria]> +-----------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -> | Table | Create Table | -> +-----------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -> | editorial | CREATE TABLE `editorial` ( -> `codedit` varchar(20) NOT NULL, -> `nombre` varchar(60) NOT NULL, -> PRIMARY KEY (`codedit`) -> ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci || libro | CREATE TABLE `libro` ( -> `idlibro` varchar(20) NOT NULL, -> `titulo` varchar(60) NOT NULL, -> `nropagina` int(11) NOT NULL, -> `precio` int(11) NOT NULL, -> `codigomat` varchar(20) NOT NULL, -> PRIMARY KEY (`idlibro`), -> KEY `codigomat` (`codigomat`), -> CONSTRAINT `libro_ibfk_1` FOREIGN KEY (`codigomat`) REFERENCES `materia` (`codigomat`) ON DELETE CASCADE ON UPDATE CASCADE -> ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci | -> +-------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -> 1 row in set (0.001 sec) -> -> MariaDB [libreria]> SHOW CREATE TABLE autor; ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '+-----------+----------------------------------------------------------------...' at line 1 MariaDB [libreria]> +-------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -> | Table | Create Table | -> +-------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -> | autor | CREATE TABLE `autor` ( -> `Codautor` varchar(20) NOT NULL, -> `nombre` varchar(60) NOT NULL, -> PRIMARY KEY (`Codautor`) -> ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci | -> +-------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -> 1 row in set (0.000 sec) -> -> MariaDB [libreria]> SHOW CREATE TABLE editorial; ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '+-------+--------------------------------------------------------------------...' at line 1 MariaDB [libreria]> +-----------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -> | Table | Create Table | -> +-----------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -> | editorial | CREATE TABLE `editorial` ( -> `codedit` varchar(20) NOT NULL, -> `nombre` varchar(60) NOT NULL, -> PRIMARY KEY (`codedit`) -> ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci | -> ; ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '+-----------+----------------------------------------------------------------...' at line 1 MariaDB [libreria]> insert into libro (idlibro, titulo, nropagina, precio, codigomat) VALUES ('L01','Calculo II',120,55000,'M01'); ERROR 1452 (23000): Cannot add or update a child row: a foreign key constraint fails (`libreria`.`libro`, CONSTRAINT `libro_ibfk_1` FOREIGN KEY (`codigomat`) REFERENCES `materia` (`codigomat`) ON DELETE CASCADE ON UPDATE CASCADE) MariaDB [libreria]> select * from materia; Empty set (0.004 sec) MariaDB [libreria]> insert into mareia (codigomat, nombre) values ('M01','matematicas'); ERROR 1146 (42S02): Table 'libreria.mareia' doesn't exist MariaDB [libreria]> insert into materia (codigomat, nombre) values ('M01','matematicas'); Query OK, 1 row affected (0.172 sec) MariaDB [libreria]> insert into libro (idlibro, titulo, nropagina, precio, codigomat) VALUES ('L01','Calculo II',120,55000,'M01'); Query OK, 1 row affected (0.147 sec) MariaDB [libreria]> select * from libro; +---------+------------+-----------+--------+-----------+ | idlibro | titulo | nropagina | precio | codigomat | +---------+------------+-----------+--------+-----------+ | L01 | Calculo II | 120 | 55000 | M01 | +---------+------------+-----------+--------+-----------+ 1 row in set (0.001 sec) MariaDB [libreria]> no tee -> ; ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'no tee' at line 1 MariaDB [libreria]> notee;