ORACLE 修改表結構 之ALTER CONSTAINTS,alterconstaints

來源:互聯網
上載者:User

ORACLE 修改表結構 之ALTER CONSTAINTS,alterconstaints

1,建立聯合主鍵

ALTER TABLE 表名 ADD CONSTRAINTS 結束名 PRIMARY KEY (列名,列名..);


2,新增字元

ALTER TABLE 表名 ADD (COLUMN DATATYPE [DEFAULT VALUE][NULL/NOT NULL]);


3,刪除列

ALTER TABLE 表名 DROP (COLUMN)J;


4,修改表的字元

ALTER TABLE 表名 MODIFY (COLUMN  DATATYPE [DEFAULT VALUE][NULL/NOT NULL])


在程式中更改Oracle資料庫的表結構

修改表名:
alter table 表名 rename to 新名
添加欄位:
alter table 表名 add 欄位名 欄位類型
刪除欄位:
alter table 表名 drop column 欄位名
修改欄位:
alter table 表名 rename column 原欄位名 to 新名;

修改欄位類型(前提:表中無資料)
alter table 表名 modify 欄位名 新類型;
例如:String deleteColumn="alter table t_user drop column sname";

希望能協助你!
 
oracle什表的資料需要用alter命令更改?

alter命令是用來改表結構 不是改資料的。屬於DDL資料定義語言 (Data Definition Language)
 

相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.