Notice
Recent Posts
Recent Comments
Link
250x250
develope_kkyu
[ORACLE] 기본키(Primary key) 본문
728x90
기본키(Primary Key; PK)는 주 키 또는 프라이머리 키라고 하며, 후보키 중에서 특별히 선정된 키.
1. 테이블 하나당 오직 하나만 존재한다. 두개이상 불가. 기본키 없는 테이블은 가능
2. 키값은 전체 컬럼을 통틀어서 유일해야(Uniqueness)
3. 키값은 null을 넣을 수 없다.(Not Null)
create table roomtype(
typenum number(3) primary key,
typename varchar(20) not null,
comments varchar2(32)
);
create table roominfo(
num varchar2(10) primary key,
name varchar2(20) not null,
type number(3), constraint fk_typenum foreign key(type) references roomtype(typenum),
howmany number(3) default 1,
howmuch number(4) default 0
);
728x90
'SQL' 카테고리의 다른 글
[ORACLE] 날짜 함수 (0) | 2022.12.27 |
---|---|
[ORACLE] 문자 함수 (0) | 2022.12.27 |
[ORACLE] 숫자 함수 (0) | 2022.12.27 |
[ORACLE] C, R, U, D 기초 (0) | 2022.12.23 |