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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Creating Primary Key

Status
Not open for further replies.

acct98

IS-IT--Management
Aug 15, 2002
194
0
0
US
I know this may be a silly question but I have to ask. Is it possible to set up a unique primay key in Oracle using a combination of fields (When used together this would create a unique key)? If yes -- Please provide example. Any assistance would be greatly appreciated.
 
Hi,

I you are creating a table

create table test (
a varchar2(10),
b varchar2(10),
c varchar2(10),
constraint pk_test
primary key (a,b) );

If you are creating a unique index

create unique index ind_test on
test (a, b) ;

Hope this helps.
 
primary key would be a really good way to approach this problem.
But what if you have 12 fields that you need to combine into a primary key. Are there any know performance issues that I should be aware of?

The reason why I am asking is because I have to figure out a way of having two merge two identical DBs, where some of the tables do not have a unique key. So, I need to compare record to record in both tables and then, based on that if they are the same, delete one.

I am sure this kind of merge functionality has been written over and over again - do you know of any code to do this?
Thanks,
Vic
victor@starsystems.co.jp

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top