Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL table create w/ concat key?

Status
Not open for further replies.

ThatRickGuy

Programmer
Oct 12, 2001
3,841
US
Anyone out there know the SQL (Oracle 8i style) to make a table with a concat Primary key?

like in a linking table, where each of the fields will have repetitions in itself, but the 2 fields together will be unique.

ex:
A | B
-----
1 | 1
1 | 2
1 | 3
2 | 1
2 | 2
2 | 3
 
If your table already exists:

alter table your_table add constraint pk_1 primary key (a, b);

If you are creating the table:

create table your_table(a varchar2(10) not null, b varchar2(10) not null,
constraint pk_1 primary key (a, b));

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top