--一本书要属于一个人
CREATE TABLE person
(
pid VARCHAR2(18) ,
name VARCHAR2(200) NOT NULL ,
age NUMBER(3) NOT NULL,
birthday DATE ,
sex VARCHAR2(2) DEFAULT '男',
CONSTRAINT person_pid_pk PRIMARY KEY(pid) ,
CONSTRAINT person_name_uk UNIQUE(name) ,
CONSTRAINT person_age_ck CHECK(age BETWEEN 0 AND 150) ,
CONSTRAINT person_sex_ck CHECK(sex IN ('男',' 女'))
) ;
CREATE TABLE book
(
bid NUMBER PRIMARY KEY NOT NULL ,
bname VARCHAR(30) ,
bprice NUMBER(5,2) ,
pid VARCHAR2(18) ,
CONSTRAINT person_book_pid_fk FOREIGN KEY(pid) REFERENCES person(pid)
) ;
转载于:https://www.cnblogs.com/ganglianhuo/p/3716596.html