1. 程式人生 > >Oracle表字段的增加、刪除、修改和重命名

Oracle表字段的增加、刪除、修改和重命名

column 表名 char arc 字段 var invoice apply efault

本文主要是關於Oracle數據庫表中字段的增加、刪除、修改和重命名的操作。

增加字段語法:alter table tablename add (column datatype [default value][null/not null],….);
說明:alter table 表名 add (字段名 字段類型 默認值 是否為空);
例:alter table sf_users add (HeadPIC blob);
例:alter table sf_users add (userName varchar2(30) default ‘空‘ not null);

修改字段的語法:alter table tablename modify (column datatype [default value][null/not null],….);
說明:alter table 表名 modify (字段名 字段類型 默認值 是否為空);
例:alter table sf_InvoiceApply modify (BILLCODE number(4));

刪除字段的語法:alter table tablename drop (column);
說明:alter table 表名 drop column 字段名;
例:alter table sf_users drop column HeadPIC;

字段的重命名:
說明:alter table 表名 rename column 列名 to 新列名 (其中:column是關鍵字)
例:alter table sf_InvoiceApply rename column PIC to NEWPIC;

表的重命名:
說明:alter table 表名 rename to 新表名
例:alter table sf_InvoiceApply rename to sf_New_InvoiceApply;

Oracle表字段的增加、刪除、修改和重命名