-
Notifications
You must be signed in to change notification settings - Fork 2
/
Dbmsday3.txt
26 lines (21 loc) · 972 Bytes
/
Dbmsday3.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
CREATE TABLE DEPT(DEPT_ID NUMBER(3) PRIMARY KEY,DEPT_NAME VARCHAR2(15));
INSERT INTO DEPT VALUES('&DEPT_ID','&DEPT_NAME');
CREATE TABLE CUST_100(EMP_ID NUMBER(3) PRIMARY KEY,
FIRST_NAME VARCHAR2(10),
LAST_NAME VARCHAR2(10),
E_MAIL VARCHAR2(10),
PH_NO VARCHAR2(15),
HIRE_DATE DATE,
JOB_ID VARCHAR2(10),
SALARY NUMBER(8,2),
MGR_ID NUMBER(3),
DEPT_ID NUMBER(3),
CHECK(FIRST_NAME=INITCAP(FIRST_NAME)),
CHECK(LAST_NAME IS NOT NULL),
CHECK(E_MAIL=UPPER(E_MAIL)),
CHECK(HIRE_DATE>'01-JAN-1980'),
CHECK(JOB_ID LIKE 'FI%' OR JOB_ID LIKE 'AD%' OR JOB_ID LIKE 'IT%'),
CHECK(SALARY BETWEEN 4000 AND 25000),FOREIGN KEY(DEPT_ID) REFERENCES DEPT(DEPT_ID));
DESC USER_CONSTRAINTS;//EXPANDS USER CONSTRAINTS TABLE
SELECT CONSTRAINT_NAME,CONSTRAINT_TYPE,SEARCH_CONDITION FROM USER_CONSTRAINTS WHERE TABLE_NAME='CUST_100';
INSERT INTO CUST_100 VALUES('&EMP_ID','&FIRST_NAME','&LAST_NAME','&E_MAIL','&PH_NO','HIRE_DATE','&JOB_ID','&SALARY','&MGR_ID','&DEPT_ID');