三种完整性约束关系例子
<DIV>1.参照完整性</DIV><DIV>SQL> create table testc(code number,<BR> 2 class varchar2(10),<BR> 3 xueke varchar2(8),<BR> 4 constraint c2 foreign key(code) references tests(code));</DIV>
<DIV> </DIV>
<DIV>2.实体完整性</DIV>
<DIV>SQL> create table tests(name varchar2(4),<BR> 2 code number,<BR> 3 note varchar2(8),<BR> 4 constraint c1 primary key(code));</DIV>
<DIV> </DIV>
<DIV>3.用户自定义完整性</DIV>
<DIV>SQL> create table testz(name varchar(6) constraint z1 not null,<BR>2 age number constraint z2 check (age between 18 and 30),<BR>3 *** varchar (6) constraint z3 check (*** in('男','女')),<BR>4 douname varchar(6) constraint z4 unique); </DIV>
页:
[1]