Created
May 8, 2025 17:24
-
-
Save diegoolipa/34420759c6c6352270dd2ff559fbd1fc to your computer and use it in GitHub Desktop.
comandos para crear mi base de datos en sql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
estado NUMBER(1) DEFAULT 1, -- 1 = activo, 0 = inactivo | |
CONSTRAINT fk_usuarios_crea FOREIGN KEY (id_usuario_crea) | |
REFERENCES s_usuarios(id_usuario), | |
CONSTRAINT fk_usuarios_actualiza FOREIGN KEY (id_usuario_actualiza) | |
REFERENCES s_usuarios(id_usuario) | |
); | |
CREATE TABLE s_categoria ( | |
id_categoria NUMBER PRIMARY KEY, | |
nombre_categoria VARCHAR2(100) NOT NULL, | |
descripcion VARCHAR2(255), | |
estado NUMBER(1) DEFAULT 1 -- 1 = activo, 0 = inactivo | |
); | |
CREATE TABLE s_producto ( | |
id_producto NUMBER PRIMARY KEY, | |
nombre_producto VARCHAR2(100) NOT NULL, | |
precio NUMBER(10,2) NOT NULL, | |
stock NUMBER DEFAULT 0, | |
id_categoria NUMBER, | |
id_usuario_creador NUMBER, | |
fecha_creacion DATE DEFAULT SYSDATE, | |
fecha_actualizacion DATE, | |
id_usuario_crea NUMBER, | |
id_usuario_actualiza NUMBER, | |
estado NUMBER(1) DEFAULT 1, -- 1 = activo, 0 = inactivo | |
CONSTRAINT fk_producto_categoria FOREIGN KEY (id_categoria) | |
REFERENCES s_categoria(id_categoria), | |
CONSTRAINT fk_producto_usuario_creador FOREIGN KEY (id_usuario_creador) | |
REFERENCES s_usuarios(id_usuario), | |
CONSTRAINT fk_producto_crea FOREIGN KEY (id_usuario_crea) | |
REFERENCES s_usuarios(id_usuario), | |
CONSTRAINT fk_producto_actualiza FOREIGN KEY (id_usuario_actualiza) | |
REFERENCES s_usuarios(id_usuario) | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment