Bases de datos sql

Solo disponible en BuenasTareas
  • Páginas : 2 (296 palabras )
  • Descarga(s) : 0
  • Publicado : 28 de abril de 2011
Leer documento completo
Vista previa del texto
-- ------------------- --
-- CREAR LA TABLA DEPT --
-- ------------------- --
CREATE TABLE DEPT (
DEPTNO INT NOT NULL PRIMARY KEY,
DNAME CHAR (10) NOT NULL,
LOC CHAR (8) NOT NULL
)-- ------------------- --
-- CREAR LA TABLA EMP --
-- ------------------- --
CREATE TABLE EMP (
ENO INT NOT NULL PRIMARY KEY,
ENAME CHAR (6) NOT NULL,
JOB CHAR (9)NOT NULL,
MGR INT NULL,
HIREDATE DATETIME NOT NULL,
SAL INT NOT NULL,
COMM INT NULL,
DEPTNO INT NOT NULL REFERENCES DEPT
)

ALTER TABLE EMPADD CONSTRAINT MANAGER FOREIGN KEY (MGR) REFERENCES EMP

-- ----------------------- --
-- CREAR LA TABLA SALGRADE --
-- ----------------------- --
CREATE TABLE SALGRADE (
GRADE INT NOTNULL PRIMARY KEY,
LOSAL INT NOT NULL,
HISAL INT NOT NULL
)

-- ------------------- --
-- CREAR LA TABLA DEPT --
-- ------------------- --
CREATE TABLE DEPT (
DEPTNO INT NOT NULLPRIMARY KEY,
DNAME CHAR (10) NOT NULL,
LOC CHAR (8) NOT NULL
)

-- ------------------- --
-- CREAR LA TABLA EMP --
-- ------------------- --
CREATE TABLE EMP (
ENO INTNOT NULL PRIMARY KEY,
ENAME CHAR (6) NOT NULL,
JOB CHAR (9) NOT NULL,
MGR INT NULL,
HIREDATE DATETIME NOT NULL,
SAL INT NOT NULL,
COMM INTNULL,
DEPTNO INT NOT NULL REFERENCES DEPT
)

ALTER TABLE EMP ADD CONSTRAINT MANAGER FOREIGN KEY (MGR) REFERENCES EMP

-- ----------------------- --
-- CREAR LA TABLA SALGRADE --
------------------------- --
CREATE TABLE SALGRADE (
GRADE INT NOT NULL PRIMARY KEY,
LOSAL INT NOT NULL,
HISAL INT NOT NULL
)

-- ------------------- --
-- CREAR LA TABLA DEPT--
-- ------------------- --
CREATE TABLE DEPT (
DEPTNO INT NOT NULL PRIMARY KEY,
DNAME CHAR (10) NOT NULL,
LOC CHAR (8) NOT NULL
)

-- ------------------- --
-- CREAR LA TABLA...
tracking img