sql新增 刪除 修改

2021-08-29 02:34:43 字數 745 閱讀 8712

新增欄位的語法:alter table tablename add (column datatype [default value][null/not null],….);

//被修改的字段需為null

修改欄位的語法:alter table tablename modify (column datatype [default value][null/not null],….);

刪除欄位的語法:alter table tablename drop (column);

增加乙個字段:

alter table test1 add (name varchar2(30) default 『預設值』 not null);

同時新增三個字段:

alter table test1 add 

(name varchar2(30) default 『預設值』 not null,

age integer default 22 not null,

has_money number(9,2)

);修改乙個字段:

alter table test1 modify (name varchar2(16) default 『unknown』);

刪除乙個字段:

alter table test1 drop column name;

字段增加注釋:

comment on column 表名.name is '備註';

sql 新增 修改 刪除 約束

1.向表中新增新的字段 alter table table name add column name varchar2 20 not null 2.刪除表中的乙個字段 alter table table name drop column column name 3.修改表中的乙個欄位名 alter ...

SQL語句新增刪除修改字段

1.查詢字段預設值約束的名字 t1為表名,id為欄位名 select a.name as 使用者表,b.name as 欄位名,d.name as 字段預設值約束 from sysobjects a,syscolumns b,syscomments c,sysobjects d where a.id...

用SQL語句新增刪除修改字段

增加字段 alter table docdsp add dspcode char 200 刪除字段 alter table table name drop column column name 修改字段型別 alter table table name alter column column nam...