Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: insert into another table with 2 primary keys.

Re: insert into another table with 2 primary keys.

From: Randall <aslan_at_pcmagic.net>
Date: Wed, 23 Sep 1998 07:35:33 -0700
Message-ID: <36090730.D3AE8F71@pcmagic.net>


You say you have two primary keys in t1, but I think what you mean is you have a compound key. Your primary key appears to be a concatenation of t1 and t2. t1 by itself cannot be primary because the value 2 repeats. A primary key, by definition, has no repeating values in the key. Both t1 and t2 have repeating values, but concatenated they do not. And, by definition, a table never has two primary keys. Columns or combinations of columns that must not be duplicated within the database are referred to as candidate keys. The "primary" key is the candidate key that the developer feels will be used most often to query the database.

If I understand correctly you want to append t2 to t1, but in your example you don't want to append the first row of t2. In your application is there more than one row that you don't to append? What is the condition for which you wish to omit records... the -1 in cc4?

> I have two table t1(with two primary keys c1 and c2) and t2
>
> t1
> c1 c2 c3 c4
> 2 5 1 0
> 2 4 1 0
> 5 2 0 1
> 4 2 0 1
> 2 2 1 1
>
>
> t2
> cc1 cc2 cc3 cc4
> 2 4 1 -1
> 2 3 0 1
> 2 5 0 1
> 2 2 0 1
>
> I want to insert t2's data into t1 and the t2(2,4,1,-1) should not be
> inserted into t1 table and so on... Does anyone know how to do it?
>
Received on Wed Sep 23 1998 - 09:35:33 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US