Add a joint primary key in oracle and an oracle joint primary key

Source: Internet
Author: User

Add a joint primary key in oracle and an oracle joint primary key

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


In the preceding statement:

Tablename is the table for which the Union constraint is to be added.

Unionkeyname is the name of the added Union constraint.

Column1 and column2 are the names of the two columns used by the Union primary key.


Oracle joint primary key Creation

Alter table xxx add constraints xxx_pk primary key (c1, c2, c3, c4, c5 ....);

In Oracle, how does one set the Union primary key? (Example)

Set during table Creation
Create table tab (
ID1 NUMBER (10 ),
ID2 NUMBER (4 ),
Credit number (2 ),
CONSTRAINT PK_TAB primary key (ID1, ID2) -- PRIMARY KEY
);
Or append after creating the table
Alter table tab add constraint pk_tab2 primary key (id1, id2 );

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.