運用sql語句增刪改欄位

2021-04-12 22:48:28 字數 588 閱讀 5285

增加字段

alter table docdsp  add dspcode char(200)

刪除字段

alter table table_name drop column column_name

修改字段型別

alter table table_name  alter column column_name new_data_type

重新命名表:(access 重新命名表,請參考文章:在access資料庫中重新命名表)

sp_rename '表名', '新錶名', 'object'

新建約束:

alter table [表名] add constraint 約束名 check ([約束字段] <= '2000-1-1')

刪除約束:

alter table [表名] drop constraint 約束名

新建預設值

alter table [表名] add constraint 預設值名 default '51windows.net' for [欄位名]

刪除預設值

alter table [表名] drop constraint 預設值名

dhl 增刪改sql欄位的sql語句

如需在表中新增列,請使用下列語法 alter table table name addcolumn name datatype 例如 alter table persons addbirthday date 要刪除表中的列,請使用下列語法 alter table table name drop co...

SQL語句 增刪改

程式設計要求use test wyy db guet goset nocount on begin 此處寫第一題的sql語句 insert into student sno,sname,s sage,sdept values 07002 lucy f 21 ma end go begin 此處寫第二...

mysql 增刪改欄位語句

1 增加字段 增加乙個字段,預設為空 alter table user add column new1 varchar 20 default null 增加乙個字段,預設不能為空 alter table user add column new2 varchar 20 not null 2 批量增加字...