zoukankan      html  css  js  c++  java
  • SQL Server

     代码实现为表添加相关约束

      select * from Student
      --删除表中的某一列
      alter table Student drop column stdAddress      
      --为某个表增加一列
      alter    table Student add StdAddress nvarchar(50) 
      --修改某一列的数据类型
      alter table Student alter column StdAddress varchar(50)
      --为某个字段增加一个主键约束
      alter table Student add constraint PK_Student_StdId primary key (StdId)
      --为某个字段增加一个非空约束
      alter table Student alter column StdId int not null;
      alter table Student alter column StdUserName nvarchar(10) not null;
      --为某个字段增加一个唯一约束
      alter table Student add constraint UK_Student_StdUserName unique (StdUserName)
      --为某一列添加一个默认约束
      alter table Student add constraint DF_Student_StdGender default('') for StdGender
      --为某一列添加一个检查约束
      alter table Student add constraint CF_Student_StdGender check(StdGender='' or StdGender='')
      --为某一列添加一个外键约束
      alter table Student add constraint FK_Student_Class_ClassId foreign key(ClassId) references Class(ClassId)

      作者:Jeremy.Wu
      出处:https://www.cnblogs.com/jeremywucnblog/
      本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。

  • 相关阅读:
    锋利的BFC
    inline和inline-block的间隙问题
    margin和padding的四种写法
    js中Math.round、parseInt、Math.floor和Math.ceil小数取整小结
    使用vscode自动编译less
    redux获取store中的数据
    react显示隐藏动画
    react使用路由
    react中使用fetchjsonp获取数据
    vue兼容到ie9
  • 原文地址:https://www.cnblogs.com/jeremywucnblog/p/12460908.html
Copyright © 2011-2022 走看看