设置非空约束

USE CSDN
alter table csdn alter column c1 int not null
利用ALTER TABLE来增加约束

设置主键

USE CSDN
alter table csdn add constraint pk primary key(c1)
利用ALTER TABLE来增加约束

设置取值范围

USE CSDN
alter table csdn add constraint ck check(c1>=0 AND c1<=100)
利用ALTER TABLE来增加约束

设置默认值

USE CSDN
alter table csdn add constraint de default(‘网络工程’)for c2
利用ALTER TABLE来增加约束

引入外键

USE CSDN
alter table css add constraint fk foreign key (c1) references csdn(c1)

利用ALTER TABLE来增加约束
利用ALTER TABLE来增加约束

删除约束

以删除 css表的外键约束为例:
USE CSDN
alter table css drop constraint fk
利用ALTER TABLE来增加约束

相关文章:

  • 2022-12-23
  • 2021-09-12
  • 2022-12-23
  • 2022-12-23
  • 2021-07-12
  • 2021-07-30
  • 2022-12-23
  • 2021-12-27
猜你喜欢
  • 2021-12-31
  • 2022-12-23
  • 2022-12-23
  • 2021-08-16
  • 2022-02-15
  • 2022-02-08
  • 2022-12-23
相关资源
相似解决方案