Chinaunix首页 | 论坛 | 博客
  • 博客访问: 54389
  • 博文数量: 8
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 115
  • 用 户 组: 普通用户
  • 注册时间: 2017-08-30 17:40
个人简介

彼岸存在但不可感知,所以彼岸无从知晓。

文章分类

全部博文(8)

文章存档

2021年(1)

2019年(7)

我的朋友

分类: SQLServer

2019-11-27 14:37:54

------增加列------

1.alter table table_name  add column_name column_tpye        

------修改列------

2.alter table table_name alter column column_name column_type  

------删除列------

3.alter table table_name drop column column_name     

-------------------------------------------------------------

 扩展以下

-------------------------------------------------------------

------修改列名------

 4.exec sp_rename '表名.列名','新列名'   

------修改表名------

5.exec sp_rename '原表名’,'新表名'

------增加主键------

6.Alter table 表名 add constraint  约束名 primary key(列名)

------增加唯一约束------

7.Alter table 表名 add constraint  约束名 unique(列名)

------增加列的默认值------

8.Alter table 表名 add constraint 约束名 default(默认值) for 列名

------增加约束------

9.Alter table 表名 add constraint 约束名 check (内容)

------增加外键约束------

10.Alter table 表名 add constraint 约束名  foreign key(列名) referencese 另一表名(列名)


------删除约束------


11.Alter table 表名 drop constraint 约束名 



阅读(5618) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~