check约束

alter table emp add constraint abcdefg  check(sal>0 and SAL<100000);

 alter table emp add constraint abcde  check(SAL>0);

create table customer(
cid number(10) primary key,
cname varchar2(20),
caddr varchar2(40),
cmail number(6),
ctel number(12),
check(
  cmail>0 and ctel>0
)
)
select * from customer
create table stock(
sid number(10) primary key,
sname varchar2(20),
sprice number(10),
check(sprice>0)
)
select * from stock
create table purchase (
pid number(10),
pcid varchar2(10),
porderdate date,
pdeliverdate date,
pdeliveraddr varchar2(40),
pmail number(6),
check(porderdate<pdeliverdate) ,
check(pmail>0 and pid>0)
)
select * from purchase
create table items(
iid number(8) primary key,
ipid number(10) references purchase(pid),
isid number(10) references stock(sid),
inum number(10),
idiscount number(6),
check(ipid>0 and iid>0 and isid>0 and inum>0 and idiscount>0)
)
select * from items
drop table items

 

你可能感兴趣的:(Date,table)