SQL QUREIES
CREATE TABLE DEPAT :CREATE TABLE DEPART ( DNO VARCHAR2(3) CONSTRAINT D_LIKE_CONS CHECK( DNO LIKE 'D%') CONSTRAINT DNO_UNO_CONS UNIQUE,
DANAME VARCHAR(10) CONSTRAINT DNAME_UNQ_CONS UNIQUE,
LOCATION VARCHAR(9) CONSTRAINT VALID_LOC_CONS CHECK( LOCATION IN ('BNG','MNG','MUB','HYD')));
CREATE TABLE PROJ (DNO VARCHAR2(3) CONSTRAINT DNO_FK_DEPART_CONS REFERENCES DEPART(DNO) NOT NULL,
PRJ_NO VARCHAR2(5) CONSTRAINT PROJ_NO_LIKE CHECK(PRJ_NO LIKE 'P%') NOT NULL,
PRJ_NAME VARCHAR2(10),
PRJ_CREDIT NUMBER(2) CONSTRAINT PRJ_CREIDET_RANGE_CONS CHECK(PRJ_CREDIT BETWEEN 1 AND 10),
START_DATE DATE,
END_DATE DATE,
CONSTRAINT END_DATE_GRT_STARDATE_CONS CHECK(END_DATE > START_DATE));
CREATE TABLE EMP :
CREATE TABLE EMP (EMPNO NUMBER(4) PRIMARY KEY,
ENAME VARCHAR2(10),
JOB VARCHAR2(9) CONSTRAINT JOB_CHK_CONS CHECK (JOB IN ('CLRK','MGR','A.MGR','GM','CEO')),
MGRID NUMBER(4) CONSTRAINT MGR_FK_EMPNO_CONS REFERENCES EMP,
DATE_BIRTH DATE,
SAL NUMBER(7,2) CONSTRAINT SAL_20K_CONS CHECK(SAL > 200000),
COMM NUMBER(7,2) DEFAULT 1000,
DEPTNO VARCHAR2(3),
DATE_JOIN DATE,
CONSTRAINT DB_LESS_DBJOIN_CONS CHECK (DATE_BIRTH < DATE_JOIN));
Comments
Post a Comment