创建表--添加字段,更新字段

1、建表

create table test_table (
  id int identity (1,1) primary key
)

2、添加字段

ALTER table 表名 add 字段名 字段类型 null

3、更新字段 

ALTER table 表名 alter COLUMN 字段名 字段类型 

4、删除字段

ALTER table 表名 drop COLUMN 字段名1,字段名2...

5、修改对象名

  A. 重命名表
  下例将表 customers 重命名为 custs
  EXEC sp_rename 'customers', 'custs'
  B. 重命名列
  下例将表 customers 中的列 contact_title 重命名为 title。
  EXEC sp_rename 'customers.[contact title]', 'title', 'COLUMN'

 

posted on 2016-03-23 15:31  li_le  阅读(201)  评论(0)    收藏  举报

导航