ORACLE中通过SQL语句(alter table)来增加、删除、修改字段

来源:互联网 发布:望各位悉知 编辑:程序博客网 时间:2024/05/19 13:14


1.添加字段:

alter table  表名  add (字段  字段类型)  [ default  '输入默认值']  [null/not null]  ;


alter table ES_ORDER_PROD_ATTR add SI_CODE VARCHAR2(255);


2.添加备注:

comment on column  库名.表名.字段名 is  '输入的备注';  如: 我要在ers_data库中  test表 document_type字段添加备注  comment on column ers_data.test.document_type is '文件类型';


-- Add comments to the columns 
comment on column ES_ORDER_PROD_ATTR.SI_CODE
  is 'SI编码';

3.修改字段类型:

alter table 表名  modify (字段  字段类型  [default '输入默认值' ] [null/not null]  ,字段  字段类型  [default '输入默认值' ] [null/not null] ); 修改多个字段用逗号隔开


4.删除字段:

alter table  表名  drop (字段);


alter table ES_ORDER_PROD_ATTR drop (test);


括号不能省略















阅读全文
0 0