반응형

1.
CREATE TABLE DEPT_TEST(
ID NUMBER(7),
NAME VARCHAR2(25),
CONSTRAINT DEPT_TEST_ID_PK PRIMARY KEY (ID)
)
;

 

2.
INSER INTO DEPT_TEST
 SELECT DEPARTMENT_ID, DEPARTMENT_NAME
 FROM DEPARTMENTS
;

 

3.
CREATE TABLE EMP_TEST(
ID NUMBER(7),
LAST_NAME VARCHAR2(25),
FIRST_NAME VARCHAR2(25),
DEPT_ID NUMBER(7),
CONSTRAINT EMP_DEPT_TEST_FK FOREIGN KEY(DEPT_ID) REFERENCES DEPT_TEST(ID)
)
;

 

4.
CREATE TABLE EMP_TEST2
AS SELECT EMPLOYEE_ID ID, FIRST_NAME, LAST_NAME, SALARY, DEPARTMENT_ID DEPT_ID
FROM EMPLOYEES WHERE 1 = 2;

 

5.
DROP TABLE EMP_TEST2;

 

반응형