오라클 테스트 예제로 많이 나오는
EMP, DEPT 테이블
생성 스크립트
EMP, DEPT 테이블 생성 스크립트
CREATE TABLE DEPT(
DEPTNO NUMBER(2, 0)
, DNAME VARCHAR2(14)
, LOC VARCHAR2(13)
, CONSTRAINT PK_DEPT PRIMARY KEY (DEPTNO)
);
CREATE TABLE EMP(
EMPNO NUMBER(4, 0)
, ENAME VARCHAR2(10)
, JOB VARCHAR2(9)
, MGR NUMBER(4, 0)
, HIREDATE DATE
, SAL NUMBER(7, 2)
, COMM NUMBER(7, 2)
, DEPTNO NUMBER(2, 0)
, CONSTRAINT PK_EMP PRIMARY KEY (EMPNO), CONSTRAINT FK_DEPTNO FOREIGN KEY (DEPTNO) REFERENCES DEPT (DEPTNO)
);
INSERT INTO DEPT VALUES (10, 'ACCOUNTING', 'NEW YORK');
INSERT INTO DEPT VALUES (20, 'RESEARCH', 'DALLAS');
INSERT INTO DEPT VALUES (30, 'SALES', 'CHICAGO');
INSERT INTO DEPT VALUES (40, 'OPERATIONS', 'BOSTON');
INSERT INTO EMP VALUES (7839,'KING','PRESIDENT',NULL,TO_DATE('1981-11-17','YYYY-MM-DD'),5000,NULL,10);
INSERT INTO EMP VALUES (7698,'BLAKE','MANAGER',7839,TO_DATE('1981-05-01','YYYY-MM-DD'),2850,NULL,30);
INSERT INTO EMP VALUES (7782,'CLARK','MANAGER',7839,TO_DATE('1981-05-09','YYYY-MM-DD'),2450,NULL,10);
INSERT INTO EMP VALUES (7566,'JONES','MANAGER',7839,TO_DATE('1981-04-01','YYYY-MM-DD'),2975,NULL,20);
INSERT INTO EMP VALUES (7654,'MARTIN','SALESMAN',7698,TO_DATE('1981-09-10','YYYY-MM-DD'),1250,1400,30);
INSERT INTO EMP VALUES (7499,'ALLEN','SALESMAN',7698,TO_DATE('1981-02-11','YYYY-MM-DD'),1600,300,30);
INSERT INTO EMP VALUES (7844,'TURNER','SALESMAN',7698,TO_DATE('1981-08-21','YYYY-MM-DD'),1500,0,30);
INSERT INTO EMP VALUES (7900,'JAMES','CLERK',7698,TO_DATE('1981-12-11','YYYY-MM-DD'),950,NULL,30);
INSERT INTO EMP VALUES (7521,'WARD','SALESMAN',7698,TO_DATE('1981-02-23','YYYY-MM-DD'),1250,500,30);
INSERT INTO EMP VALUES (7902,'FORD','ANALYST',7566,TO_DATE('1981-12-11','YYYY-MM-DD'),3000,NULL,20);
INSERT INTO EMP VALUES (7369,'SMITH','CLERK',7902,TO_DATE('1980-12-09','YYYY-MM-DD'),800,NULL,20);
INSERT INTO EMP VALUES (7788,'SCOTT','ANALYST',7566,TO_DATE('1982-12-22','YYYY-MM-DD'),3000,NULL,20);
INSERT INTO EMP VALUES (7876,'ADAMS','CLERK',7788,TO_DATE('1983-01-15','YYYY-MM-DD'),1100,NULL,20);
INSERT INTO EMP VALUES (7934,'MILLER','CLERK',7782,TO_DATE('1982-01-11','YYYY-MM-DD'),1300,NULL,10);
COMMIT ;
SELECT * FROM EMP ;
SELECT * FROM DEPT ;
'DBMS > ORACLE' 카테고리의 다른 글
오라클 NTILE 함수 설명 및 사용법 (0) | 2023.10.03 |
---|---|
오라클 START WITH ... CONNECT BY(계층쿼리) 사용법 (0) | 2023.09.15 |
오라클 null 처리 함수(nvl, nvl2, nullif, coalesce) (0) | 2023.09.09 |
오라클 숫자(number), 날짜(date) 타입 컬럼 byte size 구하기 (0) | 2023.09.05 |
Orange, QueryBox 등 쿼리툴에서 xplan 안될 때 해결법 (0) | 2023.08.31 |
댓글