sql语句对表的操作

来源:互联网 发布:fanuc pmc编程手册 编辑:程序博客网 时间:2024/05/17 01:50

添加字段:

ALTER TABLE [t_team] ADD change int DEFAULT 0
ALTER TABLE [t_team_price] ADD change int DEFAULT 0

删除字段: 

alter table [表名] drop 字段名

修改字段:

一、修改字段默认值


alter table 表名 drop constraint 约束名字   ------说明:删除表的字段的原有约束


alter table 表名 add constraint 约束名字 DEFAULT 默认值 for 字段名称 -------说明:添加一个表的字段的约束并指定默认值


二、修改字段名:


alter table 表名 rename column A to B


sql server:

EXEC sp_rename 't_team.[change]','ichange','COLUMN';


三、修改字段类型:


alter table 表名 modify column UnitPrice decimal(18, 4) not null 


三、修改增加字段:


alter table 表名 ADD 字段 类型 NOT NULL Default 0


0 0
原创粉丝点击