Schema Table Used For Queries

******************************************************************************
Employee Table:

CREATE TABLE EMP(EMPNO INT UNIQUE,ENAME VARCHAR(20),JOB VARCHAR(20),MGR INT,HIREDATE DATE,SAL INT,COMM INT,DEPTNO INT )

SELECT * FROM EMP

INSERT INTO "SYSTEM"."EMP" (EMPNO, ENAME, JOB, MGR, HIREDATE, SAL, DEPTNO) VALUES ('7839', 'KING', 'PRESIDENT', '0', TO_DATE('1981-11-17 00:00:00', 'YYYY-MM-DD HH24:MI:SS'), '5000', '10');
INSERT INTO "SYSTEM"."EMP" (EMPNO, ENAME, JOB, MGR, HIREDATE, SAL, DEPTNO) VALUES ('7698', 'BLAKE', 'MANAGER', '7839', TO_DATE('1981-05-01 00:00:00', 'YYYY-MM-DD HH24:MI:SS'), '2850', '30');
INSERT INTO "SYSTEM"."EMP" (EMPNO, ENAME, JOB, MGR, HIREDATE, SAL, DEPTNO) VALUES ('7782', 'CLARK', 'MANAGER', '7839', TO_DATE('1981-06-09 00:00:00', 'YYYY-MM-DD HH24:MI:SS'), '2450', '10');
INSERT INTO "SYSTEM"."EMP" (EMPNO, ENAME, JOB, MGR, HIREDATE, SAL, DEPTNO) VALUES ('7566', 'JONES', 'MANAGER', '7839', TO_DATE('1981-04-02 00:00:00', 'YYYY-MM-DD HH24:MI:SS'), '2975', '20');
INSERT INTO "SYSTEM"."EMP" (EMPNO, ENAME, JOB, MGR, HIREDATE, SAL, DEPTNO) VALUES ('7788', 'SCOTT', 'ANALYST', '7566', TO_DATE('1982-12-09 00:00:00', 'YYYY-MM-DD HH24:MI:SS'), '3000', '20');
INSERT INTO "SYSTEM"."EMP" (EMPNO, ENAME, JOB, MGR, HIREDATE, SAL, DEPTNO) VALUES ('7902', 'FORD', 'ANALYST', '7566', TO_DATE('1981-12-03 00:00:00', 'YYYY-MM-DD HH24:MI:SS'), '3000', '20');
INSERT INTO "SYSTEM"."EMP" (EMPNO, ENAME, JOB, MGR, HIREDATE, SAL, DEPTNO) VALUES ('7369', 'SMITH', 'ANALYST', '7902', TO_DATE('1980-12-17 00:00:00', 'YYYY-MM-DD HH24:MI:SS'), '800', '20');
INSERT INTO "SYSTEM"."EMP" (EMPNO, ENAME, JOB, MGR, HIREDATE, SAL, COMM, DEPTNO) VALUES ('7499', 'ALLEN', 'CLERK', '7698', TO_DATE('1981-02-20 00:00:00', 'YYYY-MM-DD HH24:MI:SS'), '1600', '300', '30');
INSERT INTO "SYSTEM"."EMP" (EMPNO, ENAME, JOB, MGR, HIREDATE, SAL, COMM, DEPTNO) VALUES ('7521', 'WARD', 'SALESMAN', '7698', TO_DATE('1981-02-22 00:00:00', 'YYYY-MM-DD HH24:MI:SS'), '1250', '500', '30');
INSERT INTO "SYSTEM"."EMP" (EMPNO, ENAME, JOB, MGR, HIREDATE, SAL, COMM, DEPTNO) VALUES ('7654', 'MARTIN', 'SALESMAN', '7698', TO_DATE('1981-09-28 00:00:00', 'YYYY-MM-DD HH24:MI:SS'), '1250', '1400', '30');
INSERT INTO "SYSTEM"."EMP" (EMPNO, ENAME, JOB, MGR, HIREDATE, SAL, COMM, DEPTNO) VALUES ('7844', 'TURNER', 'SALESMAN', '7698', TO_DATE('1981-09-08 00:00:00', 'YYYY-MM-DD HH24:MI:SS'), '1500', '0', '30');
INSERT INTO "SYSTEM"."EMP" (EMPNO, ENAME, JOB, MGR, HIREDATE, SAL, DEPTNO) VALUES ('7876', 'AADAMS', 'CLERK', '7788', TO_DATE('1983-01-12 00:00:00', 'YYYY-MM-DD HH24:MI:SS'), '1100', '20');
INSERT INTO "SYSTEM"."EMP" (EMPNO, ENAME, JOB, MGR, HIREDATE, SAL, DEPTNO) VALUES ('7900', 'JAMES', 'CLERK', '7698', TO_DATE('1981-12-03 00:00:00', 'YYYY-MM-DD HH24:MI:SS'), '950', '30');
INSERT INTO "SYSTEM"."EMP" (EMPNO, ENAME, JOB, MGR, HIREDATE, SAL, DEPTNO) VALUES ('7934', 'MILLER', 'CLERK', '7782', TO_DATE('1982-01-23 00:00:00', 'YYYY-MM-DD HH24:MI:SS'), '1300', '10');


CREATE TABLE DEPT(DEPTNO INT PRIMARY KEY,LOC VARCHAR(20),DNAME VARCHAR(50) )

SELECT * FROM DEPT

INSERT INTO DEPT VALUES(10,'CHICAGO','ACCOUNTING');
INSERT INTO DEPT VALUES(20,'NEW YORK','RESEARCH');
INSERT INTO DEPT VALUES(30,'DALLAS','SCRIPT');

ALTER TABLE EMP ADD CONSTRAINT DN FOREIGN KEY(DEPTNO) REFERENCES DEPT(DEPTNO);



CREATE TABLE SALGRADE(GRADE INT PRIMARY KEY, LOSAL INT, HISAL INT );

INSERT INTO SALGRADE VALUES(1,3000,5000);
INSERT INTO SALGRADE VALUES(2,1600,2975);
INSERT INTO SALGRADE VALUES(3,800,1500);
*******************************************************************************
Previous
Next Post »