上传者: duan694610410
|
上传时间: 2022-02-24 09:47:45
|
文件大小: 1.22MB
|
文件类型: -
数据库创建代码:
1:用户表:(users)
userid(主键),username(用户名),password(密码),sex(性别),head(头像),regdate(注册日期)
2:类别表:(types)
tid(主键),type
3:技术表:(technic)
teid(主键),tename(技术名),tsum(拥有帖子数量),tid(引用类别表主键)
4:帖子表:(card)
cid(主键),title(标题),content(内容),outtime(发帖时间),uptime(修改帖子的时间),csum(回帖数量),tename(属于哪个技术),
userid(引用用户表外键)
5:回帖表:(restore)
rid(主键),rtitle(标题),rcontent(内容),routtime(发帖时间),ruptime(修改帖子的时间),tename(属于哪个技术),
userid(引用用户表外键),cid(引用帖子表主键)
--用户表:(users)
-- Create table
create table USERS
(
USERID INTEGER not null,
USERNAME VARCHAR2(20) not null,
PASSWORD VARCHAR2(20) not null,
SEX VARCHAR2(20) not null,
HEAD VARCHAR2(20) not null,
REGDATE DATE 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 USERS
add constraint PK_USERID primary key (USERID)
using index
tablespace SYSTEM
pctfree 10
initrans 2
maxtrans 255
storage
(
initial 64K
minextents 1
maxextents unlimited
);
--类别表:(types)
-- Create table
create table TYPES
(
TID INTEGER not null,
TYPE VARCHAR2(20) 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 TYPES
add constraint PK_TID primary key (TID)
using index
tablespace SYSTEM
pctfree 10
initrans 2
maxtrans 255
storage
(
initial 64K
minextents 1
maxextents unlimited
);
--技术表:(technic)
-- Create table
create table TECHNIC
(
TEID INTEGER not null,
TENAME VARCHAR2(20) not null,
TSUM INTEGER not null,
TID INTEGER 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 TECHNIC
add constraint PK_TEID primary key (TEID)
using index
tablespace SYSTEM
pctfree 10
initrans 2
maxtrans 255
storage
(
initial 64K
minextents 1
maxextents unlimited
);
alter table TECHNIC
add constraint FK_TID foreign key (TID)
references TYPES (TID);
--帖子表:(card)
-- Create table
create table CARD
(
CID INTEGER not null,
TITLE VARCHAR2(20) not null,
CONTENT VARCHAR2(100) not null,
OUTTIME DATE not null,
UPTIME DATE not null,
CSUM INTEGER not null,
TENAME VARCHAR2(20) not null,
USERID INTEGER
)
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 CARD
add constraint PK_CID primary key (CID)
using index
tablespace SYSTEM
pctfree 10
initrans 2
maxtrans 255
storage
(
initial 64K
minextents 1
maxextents unlimited
);
alter table CARD
add constraint FK_USERID foreign key (USERID)
references USERS (USERID);
--回帖表:(restore)
-- Create table
create table RESTORE
(
RID INTEGER not null,
RTITLE VARCHAR2(20) not null,
RCONTENT VARCHAR2(100) not null,
ROUTTIME DATE not null,
RUPTIME DATE not null,
TENAME VARCHAR2(20) not null,
USERID INTEGER not null,
CID INTEGER 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 RESTORE
add constraint PK_RID primary key (RID)
using index
tablespace SYSTEM
pctfree 10
initrans 2
maxtrans 255
storage
(
initial 64K
minextents 1
maxextents unlimited
);
alter table RESTORE
add constraint FK_CID foreign key (CID)
references CARD (CID);
alter table RESTORE
add constraint FK_UID foreign key (USERID)
references USERS (USERID);
--序列号
-- Create sequence
create sequence SEQ_CID
minvalue 1
maxvalue 9999999999
start with 1
increment by 1
cache 20
order;
--seq_userid
-- Create sequence
create sequence SEQ_USERID
minvalue 1
maxvalue 9999991
start with 1
increment by 1
cache 20
order;
--seq_tid
-- Create sequence
create sequence SEQ_TID
minvalue 1
maxvalue 99999
start with 1
increment by 1
cache 20
order;
--seq_teid
-- Create sequence
create sequence SEQ_TEID
minvalue 1
maxvalue 999999
start with 1
increment by 1
cache 20
order;
--seq_rid
-- Create sequence
create sequence SEQ_RID
minvalue 1
maxvalue 99999
start with 1
increment by 1
cache 20
order;