oracle添加聯合主鍵,oracle聯合主鍵

來源:互聯網
上載者:User

oracle添加聯合主鍵,oracle聯合主鍵

alter table tablename add constraint unionkeyname primary key (column1,column2);


上面語句中:

tablename為要添加聯合約束的表

unionkeyname為添加的聯合約束的名稱

column1,column2為聯合主鍵作用的兩個列列名


oracle建立聯合主鍵

alter table xxx add constraints xxx_pk primary key (c1,c2,c3,c4,c5....);
 
Oracle中怎設定聯合主鍵?(舉例說明)

建表時候設定
CREATE TABLE TAB (
ID1 NUMBER(10) ,
ID2 NUMBER(4),
CREDIT NUMBER(2),
CONSTRAINT PK_TAB PRIMARY KEY (ID1,ID2) -- 主鍵
);
或者建表之後追加
alter table tab add constraint pk_tab2 primary key (id1,id2);
 

相關文章

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.