数据库原理与应用第三版何玉洁第五章上机练习
1
create table book(
Bno char(6) primary key,
Bname varchar(30) not NULL,
Fauthor char(10) not NULL,
Pubtime smalldatetime,
Price decimal(3,1),
)
2
create table bookstore(
Stono char(6) primary key,
Stoname varchar(30) not NULL,
Tel char(8) check (tel like ‘[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]’),
Ad varchar(40),
Postcode char(6),
)

3
create table sell(
Bno char(6) not NULL,
Stono char(6) not NULL,
Stime smalldatetime not NULL,
Sno tinyint check (Sno >= 1),
Primary key(Bno,Stono,Stime),
foreign key (Bno) references book(Bno),
foreign key (Stono) references bookstore(Stono)
)
2)
alter table book
add printnum int check(printnum>=1000)

3)
alter table bookstore
drop column Postcode

4)
alter table sell
drop constraint CK__sell__Sno__398D8EEE(这个是我电脑自动的约束名)

alter table sell
alter column Sno int

alter table sell
add constraint sellcheck check(Sno >=1)
这里如果只用第二个命令会报错数据库原理与应用第三版何玉洁第五章上机练习
我们去掉约束,再改,然后再添加约束即可
改成我们自定义的约束名,不是系统默认的之后,再更改就不会报错了

相关文章:

  • 2021-04-08
  • 2021-10-09
  • 2021-04-30
  • 2022-01-05
  • 2021-06-27
  • 2021-05-21
  • 2021-08-07
  • 2021-11-23
猜你喜欢
  • 2021-07-07
  • 2021-05-20
  • 2021-04-07
  • 2021-05-25
  • 2021-11-12
  • 2021-04-01
  • 2021-06-05
相关资源
相似解决方案