ORACLE中通過SQL陳述句(alter table)來增加、洗掉、修改欄位
1.添加欄位:
alter table 表名 add (欄位 欄位型別) [ default ‘輸入默認值’] [null/not null] ;
2.添加備注:
comment on column 庫名.表名.欄位名 is ‘輸入的備注’; 如: 我要在ers_data庫中 test表 document_type欄位添加備注 comment on column ers_data.test.document_type is ‘檔案型別’;
3.修改欄位型別:
alter table 表名 modify (欄位 欄位型別 [default ‘輸入默認值’ ] [null/not null] ,欄位 欄位型別 [default ‘輸入默認值’ ] [null/not null] ); 修改多個欄位用逗號隔開
4.洗掉欄位:
alter table 表名 drop (欄位);
本文轉載自:https://www.cnblogs.com/kobigood/p/6293955.html
老是記不住,哎!
**
下面是一些例子
**
增加欄位語法: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;
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/247710.html
標籤:其他
上一篇:Oracle學習筆記
