티스토리 뷰
다음 표를 기반으로 테이블을 생성하십시오
A. 테이블 이름 : TITLE
Column Name | TITLE_ID | TITLE | DESCRIPTIONN | RATING | CATEGORY | RELEASE_DATE |
Key Type | PK | |||||
Null / Unique | NN | NN | ||||
Check | G, PG, R, NC17, NR | DRAMA, COMEDY, ACTION, CHILD, SCIFI, DOCUMENTARY | ||||
Data type | NUMBER | VARCHAR2 | VARCHAR2 | VARCAHR2 | VARCHAR2 | DATE |
Length | 10 | 60 | 400 | 4 | 20 |
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 27 28 29 30 | CREATE TABLE title ( titlte_id NUMBER(10) CONSTRAINT title_id_pk PRIMARY KEY, title VARCHAR2(60) CONSTRAINT title_nn NOT NULL, description VARCHAR2(400) CONSTRAINT desc_nn NOT NULL, rating VARCHAR2(4) CONSTRAINT rating_ck CHECK ( rating IN ( 'G', 'PG', 'R', 'NC17', 'NR' ) ), category VARCHAR2(20) CONSTRAINT category_ck CHECK ( category IN ( 'DRAMA', 'COMEDY', 'ACTION', 'CHILD', 'SCIFI', 'DOCUMENTARY' ) ), release_date DATE ); |
B. 테이블 이름 : TITLE_COPY
Column Name | COPY_ID | TITLE_ID | STATUS |
Key Type | PK | PK FK | |
Null / Unique | NN | ||
Check | AVAILABLE, DESTROYED, RENTED, RESERVED | ||
FK Table | TITLE | ||
fk cOLUMN | TITLE_ID | ||
Data type | NUMBER | NUMBER | VARCHAR2 |
Length | 10 | 10 | 15 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | CREATE TABLE title_copy ( copy_id NUMBER(10), title_id NUMBER(10) CONSTRAINT title_id_fk REFERENCES title(title_id), status VARCHAR2(15) CONSTRAINT status_nn NOT NULL CONSTRAINT status_ck CHECK ( status IN ( 'AVAILABLE', 'DESTROYED', 'RENTED', 'RESERVED' ) ) CONSTRAINT copy_title_id_pk PRIMARY KEY (copy_id, title-id) ); | cs |
'부산 ITWILL 학원 실습 > ORACLE' 카테고리의 다른 글
[SQL 활용] 9. 데이터정의어(DDL) - View - 뷰 수정 (0) | 2018.08.09 |
---|---|
[SQL 활용] 9. 데이터정의어(DDL) - View - 뷰 생성 (0) | 2018.08.09 |
[SQL 활용] 8. 데이터정의어(DDL) - 테이블 삭제 - 테이블 절단 (0) | 2018.08.09 |
[SQL 활용] 8. 데이터정의어(DDL) - 테이블 삭제 - 휴지통 거치지 않고 테이블 삭제하기 (0) | 2018.08.09 |
[SQL 활용] 8. 데이터정의어(DDL) - 테이블 삭제 - Flashback Table 기능 (0) | 2018.08.09 |