好友
阅读权限10
听众
最后登录1970-1-1
|
SQL> ed
已写入 file afiedt.buf
create table user_info(
name char(20) not null,
id char(20),
pw char(20) not null,
reg_time timestamp,
limit int,
primary key(id)
)
表已创建。
SQL> ed
已写入 file afiedt.buf
create table tmp_chat_record(
from_id char(20) not null,
recv_id char(20) not null,
record varchar(200),
save_time timestamp,
constraint tmp_from_user foreign key (from_id) references user_info(id),
constraint tmp_recv_user foreign key (recv_id) references user_info(id)
)
表已创建。
SQL> ed
已写入 file afiedt.buf
create table relation(
a_id char(20),
b_id char(20),
rel char(7) check( rel in ('好友','黑名单')),
primary key(a_id, b_id),
constraint user_a foreign key (a_id) references user_info(id),
constraint user_b foreign key (b_id) references user_info(id)
)
表已创建。
SQL> ed
已写入 file afiedt.buf
create sequence seq_record
increment by 1
start with 1
nomaxvalue
nocycle
cache 10
序列已创建。
SQL> ed
已写入 file afiedt.buf
create table chat_record(
id varchar(30) primary key,
from_id char(20),
recv_id char(20),
record varchar(200),
save_time timestamp,
limit varchar(3) check( limit in ('y','n'))
constraint from_use foreign key (from_id) references user_info(id),
constraint recv_use foreign key (recv_id) references user_info(id)
)
partition by list(limit )
(
partition limit_y values('y'),
partition limit_n values('n')
)
表已创建。
SQL> ed
已写入 file afiedt.buf
create trigger record_seq before insert on chat_record for each row when (new.id is null)
begin
select seq_record.nextval into:new.id from dual;
end;
触发器已创建
SQL> ed
已写入 file afiedt.buf
create table limit_chat_record(
user_id char (20),
record_id varchar(30),
constraint user_limit foreign key (user_id) references user_info(id),
constraint record_limit foreign key (record_id) references chat_record(id)
)
表已创建。
|
|