clear markdown feedback
clear markdown feedback
By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0. 3364508 fiddles created (36284 in the last week).

SELECT VERSION();
VERSION()
8.0.27
 hidden batch(es)


CREATE TABLE pais ( id VARCHAR(2) NOT NULL, nombre VARCHAR(30) NOT NULL, PRIMARY KEY (id) ); CREATE TABLE persona ( id INT NOT NULL, nombres VARCHAR(30) NOT NULL, apellidos VARCHAR(30) NOT NULL, email VARCHAR(64) NOT NULL, edad INT, website VARCHAR(128), estado ENUM('activo', 'inactivo') DEFAULT 'inactivo', -- pais INT NOT NULL, pais VARCHAR(2) NOT NULL, PRIMARY KEY(estado) );
 hidden batch(es)


-- ALTER TABLE usuario ALTER TABLE persona ADD CONSTRAINT foranea FOREIGN KEY (pais) REFERENCES pais (id) ON UPDATE CASCADE ON DELETE RESTRICT; SHOW CREATE TABLE persona;
Table Create Table
persona CREATE TABLE `persona` ( `id` int NOT NULL, `nombres` varchar(30) NOT NULL, `apellidos` varchar(30) NOT NULL, `email` varchar(64) NOT NULL, `edad` int DEFAULT NULL, `website` varchar(128) DEFAULT NULL, `estado` enum('activo','inactivo') NOT NULL DEFAULT 'inactivo', `pais` varchar(2) NOT NULL, PRIMARY KEY (`estado`), KEY `foranea` (`pais`), CONSTRAINT `foranea` FOREIGN KEY (`pais`) REFERENCES `pais` (`id`) ON DELETE RESTRICT ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
 hidden batch(es)