본문 바로가기
🌈 프로젝트/웹 프로젝트

🌻 웹프로젝트_[13] 오라클_댓글 DB 준비

by 개발자 알마 2023. 12. 31.
반응형

[1] 댓글기능


(1) 오라클 DB 테이블 생성 

시퀀스 생성 

create sequence seq_comments;

select * from user_sequences;

 

DB 테이블 생성 

오라클은 comment가 예약어라서 적용시 오류가 난다 그래서 comments로 생성했다 

create table tbl_comments(
cno number(10,0),
bno number(10,0) not null,
comments varchar2(1000) not null,
commenter varchar2(50) not null,
commentDate date default sysdate,
commentUpdate date default sysdate
);

 

PK : cno 설정 

alter table tbl_comments add constraint pk_comments primary key (cno);

 

FK 외래키 : bno 

tbl_board 참조 

alter table tbl_comments add constraint fk_board_comments 
foreign key(bno) references tbl_board(bno):

 

 

시퀀스 권한 부여 

grant select,ALTER on seq_comment to book_ex;

 

댓글 작성 

insert into tbl_comments(cno,bno,comments,commenter) 
values (seq_comment.nextval, 202,'reply','writer123');

 

 

(2) commentsDTO 생성 

(3) commentMapper 생성

CommentMapper.java , CommentMapper.xml 각각 생성

 

(4) mapper 연결 테스트 

반응형

댓글