实验一 创建数据库及表

create table paper
(
	pno char(10) primary key,
	pna char(12),
	ppr numeric(2,1),
);
create table customer
(
	cno char(8) primary key,
	cna char(10),
	adr char(120),
);

create table cp
(
	cno char(8),
	pno char(10),
	num smallint default 1,
	primary key(pno,cno),
	foreign key(cno) references customer(cno),
	foreign key(pno) references paper(pno)
);

insert into paper values('000001','人民日报','12.5');
insert into paper values('000002','解放军报','14.5');
insert into paper values('000003','光明日报','10.5');
insert into paper values('000004','青年报','11.5');
insert into paper values('000005','扬子晚报','18.5');

insert into customer values('0001','李涛','无锡市解放路123号');
insert into customer values('0002','钱金浩','无锡市人民西路234号');
insert into customer values('0003','邓杰','无锡市惠河路270号');
insert into customer values('0004','朱海红','无锡市中山东路432号');
insert into customer values('0005','欧阳阳文','无锡市中山东路532号');

insert into cp values('0001','000001',2);
insert into cp values('0001','000002',4);
insert into cp values('0001','000005',6);
insert into cp values('0002','000001',2);
insert into cp values('0002','000003',2);
insert into cp values('0002','000005',2);
insert into cp values('0003','000003',2);
insert into cp values('0003','000004',4);
insert into cp values('0004','000001',1);
insert into cp values('0004','000003',3);
insert into cp values('0004','000005',2);
insert into cp values('0005','000003',4);
insert into cp values('0005','000002',1);
insert into cp values('0005','000004',3);
insert into cp values('0005','000005',5);
insert into cp values('0005','000001',4);


你可能感兴趣的:(实验一 创建数据库及表)