개발

pk, fk 생성 예제 본문

SQL

pk, fk 생성 예제

Dev.hs 2019. 7. 21. 01:37
create table tb_reply(
    rno number(10,0),
    bno number(10,0) not null,
    reply varchar2(1000) not null,
    replyer varchar2(50) not null,
    replyDate date default sysdate,
    updateDate date default sysdate
);

alter table tb_reply add constraint pk_reply primary key(rno);

alter table tb_reply add constraint fk_reply_board foreign key (bno) references tb_board(bno);

 

tb_board 의 bno를 fk로 가짐

 

rno를 pk로 가짐

Comments