-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsql.txt
More file actions
50 lines (43 loc) · 1.37 KB
/
sql.txt
File metadata and controls
50 lines (43 loc) · 1.37 KB
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
drop table if exists board;
drop table if exists user;
drop table if exists reply;
drop table if exists cate;
drop SEQUENCE if exists cate_num;
CREATE TABLE `board` (
`bno` int(11) NOT NULL AUTO_INCREMENT,
`bcon` text NOT NULL,
`btie` varchar(100) NOT NULL,
`bwriter` varchar(10) NOT NULL,
`cate` varchar(10) DEFAULT NULL,
`bdate` datetime DEFAULT current_timestamp(),
PRIMARY KEY (`bno`)
);
CREATE TABLE `cate` (
`cate` varchar(10) primary key,
`cno` int(11) not null
);
CREATE TABLE `reply` (
`rwriter` varchar(10) NOT NULL,
`rcon` varchar(200) NOT NULL,
`bno` int(11) DEFAULT NULL,
`rno` int(11) NOT NULL AUTO_INCREMENT,
`rdate` date DEFAULT curdate(),
PRIMARY KEY (`rno`)
);
CREATE TABLE `user` (
`id` varchar(20) NOT NULL,
`password` varchar(200) DEFAULT NULL,
`name` varchar(10) NOT NULL,
`phone` varchar(20) NOT NULL,
`grade` varchar(2) DEFAULT '1',
PRIMARY KEY (`id`)
);
alter table board add CONSTRAINT `board_cate` FOREIGN KEY (`cate`) REFERENCES `cate` (`cate`);
alter table reply add CONSTRAINT `reply_board` FOREIGN KEY (`bno`) REFERENCES `board` (`bno`);
CREATE SEQUENCE cate_num
INCREMENT BY 1
START WITH 1
MINVALUE 1
MAXVALUE 999999 ;
INSERT into cate values('공지',nextval(cate_num));
INSERT into cate values('자유게시판',nextval(cate_num));