如何创建这个表,请帮忙写下sql语句!

来源:百度知道 编辑:UC知道 时间:2024/05/30 11:48:56

仅供参考:

--客户表
create table customer
(
CustomerID varchar2(20),
FirstName varchar2(20) not null,
LastName varchar2(20) not null,
Email varchar2(20),
Phone varchar2(20) not null,
constraint cus_pk primary key (CustomerID) --主键约束
);

--图书信息表
create table book
(
bno varchar2(20), --图书编号
bname varchar2(20) not null, --书名
author varchar2(20) not null, --作者
status varchar2(10) default '在库', --图书状态,默认值为'在库'
constraint b_pk primary key (bno), --主键约束
constraint b_ch check (status in ('在库','借出'))
--check约束,检查status字段是否仅仅是'在库'或者'借出'
);

--借出记录表
create table borrow_inf
(
bno varchar(20), --借出的图书编号
b_time date not null default sysdate, --借出时间
CustomerID varchar2(20), --借书人