用SQL语句创建如下的三张表:
创建表
--创建表
create table Customer(
Cno cahr(4) primary key,
Cname char(20) unique,
Sex char(2),
Address char(50) default'北京市',
check(Sex='男' or Sex='女')
)
create table Goos(
Cno char(4) primary key,
Gname char(20) not null,
Price float check(Price>0),
Category char(50),
Provider char(20)
)
create table Purchase(
Cno char(4),
Gno char(4),
Date smalldatetime,
Amount int check(Amount>0),
Primary key(Cno,Gno,Date),
foreign key(Cno) references Customer(Cno),
foreign key(Gno) references Goos(Gno)
)
插入表
--插入表
insert into Customer
values('C101','马栋梁','男','辽宁')
查询表
--查询
select Cno,Cname,Sex,Address from Customer
更新表
update Customer set Cno='C103'
where Cname='小小'
删除行
delete from Customer
where Cname='马栋梁'