sqlserver数据库中插⼊列
格式
alter table表名
add字段名类型null default默认值
下⾯代码是向 “Table_1 ”表中增加 "Order"字段,类型为int ,可空,默认值是99
alter table Table_1
add "Order" int null default99
下⾯代码是向 “Table_1 ”表中增加 "age"字段,类型为int ,不能为空
alter table Table_1
add age int not null
完整的添加,修改,删除
-
-添加
alter table Table_1
add msg nchar(10) null
--修改
alter table Table_1
alter column msg nvarchar(500) null
--删除
alter table Table_1
drop column msg
格式说明
--添加
alter table表名
add字段名类型是否空
--修改
alter table表名
alter column字段名类型是否空
--删除
alter table表名
drop column字段名记住我
延伸阅读
SQL ALTER TABLE 语句
ALTER TABLE 语句
ALTER TABLE 语句⽤于在已有的表中添加、删除或修改列。
SQL ALTER TABLE 语法
添加
如需在表中添加列,请使⽤下⾯的语法:
ALTER TABLE table_name
ADD column_name datatype
删除
如需删除表中的列,请使⽤下⾯的语法(请注意,某些数据库系统不允许这种在数据库表中删除列的⽅式):ALTER TABLE table_name
DROP COLUMN column_name
修改
要改变表中列的数据类型,请使⽤下⾯的语法:SQL Server / MS Access:
ALTER TABLE table_name
ALTER COLUMN column_name datatype
My SQL / Oracle:
ALTER TABLE table_name
MODIFY COLUMN column_name datatype
Oracle 10G 之后版本:
ALTER TABLE table_name
MODIFY column_name datatype;