-
Notifications
You must be signed in to change notification settings - Fork 0
/
建表脚本.sql
228 lines (221 loc) · 4.73 KB
/
建表脚本.sql
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
-- Create sequence
create sequence USER_SEQ
minvalue 1
maxvalue 999999999999
start with 1000
increment by 1
cache 20;
--吧表
-- Create table
create table BAR_TABLE
(
NAME VARCHAR2(64) not null,
ID NUMBER not null,
INSERTTIME DATE not null,
UPDATETIME DATE not null,
USERID NUMBER not null,
POSTID NUMBER,
INSTRUCTION VARCHAR2(2048)
)
tablespace SYSTEM
pctfree 10
pctused 40
initrans 1
maxtrans 255
storage
(
initial 64K
minextents 1
maxextents unlimited
);
-- Create/Recreate primary, unique and foreign key constraints
alter table BAR_TABLE
add constraint BAR_PRIMARYKEY primary key (ID)
using index
tablespace SYSTEM
pctfree 10
initrans 2
maxtrans 255
storage
(
initial 64K
minextents 1
maxextents unlimited
);
alter table BAR_TABLE
add constraint CREAT_USER foreign key (USERID)
references USER_TABLE (USERID);
--评论表
-- Create table
create table COMMENT_TABLE
(
NAME VARCHAR2(64) not null,
ID NUMBER not null,
INSERTTIME DATE not null,
UPDATETIME DATE not null,
USERID NUMBER not null,
USERNAME VARCHAR2(64) not null,
PARENT_ID NUMBER
)
tablespace SYSTEM
pctfree 10
pctused 40
initrans 1
maxtrans 255
storage
(
initial 64K
minextents 1
maxextents unlimited
);
-- Create/Recreate primary, unique and foreign key constraints
alter table COMMENT_TABLE
add constraint COMMENT_PRIMARYKEY primary key (ID)
using index
tablespace SYSTEM
pctfree 10
initrans 2
maxtrans 255
storage
(
initial 64K
minextents 1
maxextents unlimited
);
alter table COMMENT_TABLE
add constraint COMMENT_PARENTID foreign key (PARENT_ID)
references FLOOR_TABLE (ID);
alter table COMMENT_TABLE
add constraint COMMENT_USERID foreign key (USERID)
references USER_TABLE (USERID);
--楼层表
-- Create table
create table FLOOR_TABLE
(
NAME VARCHAR2(64) not null,
ID NUMBER not null,
USERID NUMBER not null,
USERNAME VARCHAR2(64) not null,
INSERTTIME DATE not null,
UPDATETIME DATE not null,
POST_ID NUMBER not null,
CONTENT VARCHAR2(2048)
)
tablespace SYSTEM
pctfree 10
pctused 40
initrans 1
maxtrans 255
storage
(
initial 64K
minextents 1
maxextents unlimited
);
-- Create/Recreate primary, unique and foreign key constraints
alter table FLOOR_TABLE
add constraint FLOOR_PRIMARYKEY primary key (ID)
using index
tablespace SYSTEM
pctfree 10
initrans 2
maxtrans 255
storage
(
initial 64K
minextents 1
maxextents unlimited
);
alter table FLOOR_TABLE
add constraint FLOOR_POSTID foreign key (POST_ID)
references POST_TABLE (ID);
alter table FLOOR_TABLE
add constraint FLOOR_USERID foreign key (USERID)
references USER_TABLE (USERID);
--帖子表
-- Create table
create table POST_TABLE
(
NAME VARCHAR2(64) not null,
ID NUMBER not null,
THEME VARCHAR2(256),
USERID NUMBER not null,
USERNAME VARCHAR2(64) not null,
INSERTTIME DATE not null,
UPDATETIME DATE not null,
BAR_ID NUMBER not null
)
tablespace SYSTEM
pctfree 10
pctused 40
initrans 1
maxtrans 255
storage
(
initial 64K
minextents 1
maxextents unlimited
);
-- Create/Recreate primary, unique and foreign key constraints
alter table POST_TABLE
add constraint POST_PRIMARYKEY primary key (ID)
using index
tablespace SYSTEM
pctfree 10
initrans 2
maxtrans 255
storage
(
initial 64K
minextents 1
maxextents unlimited
);
alter table POST_TABLE
add constraint POST_BAR foreign key (BAR_ID)
references BAR_TABLE (ID);
alter table POST_TABLE
add constraint POST_USERID foreign key (USERID)
references USER_TABLE (USERID);
--用户表
-- Create table
create table USER_TABLE
(
USERNAME VARCHAR2(64) not null,
USERID NUMBER not null,
INSERTTIME DATE not null,
AGE NUMBER,
SEX CHAR(1),
INTRODUCTION VARCHAR2(1024),
STATUS CHAR(1),
UPDATETIME DATE not null,
EMAIL VARCHAR2(32),
QQ NUMBER,
PHONE NUMBER,
PASSWORD VARCHAR2(20),
BIRTH DATE
)
tablespace SYSTEM
pctfree 10
pctused 40
initrans 1
maxtrans 255
storage
(
initial 64K
minextents 1
maxextents unlimited
);
-- Create/Recreate primary, unique and foreign key constraints
alter table USER_TABLE
add constraint PRIMARYKEY primary key (USERID)
using index
tablespace SYSTEM
pctfree 10
initrans 2
maxtrans 255
storage
(
initial 64K
minextents 1
maxextents unlimited
);