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: Will blank key cause error???

Re: Will blank key cause error???

From: Grue <grue_at_hotmail.com>
Date: 1998/01/29
Message-ID: <34d0aa80.6150104@128.158.254.10>#1/1

You need to use a UNIQUE constraint instead of a PRIMARY KEY constraint in this case. You can define a composite unique key in your CREATE TABLE statement as follows:

CREATE TABLE foo
(

     column1     varchar2(10),
     column2     varchar2(10),
     column3     varchar2(10),
     UNIQUE (column1, column2, column3)

);

Here's how the composite unique key works, as described in the Oracle SQL Language Reference Manual:

" To satisfy a constraint that designates a composite unique key, no two rows in the table can have the same combination of values in the key columns. Also, any row that contains nulls in all key columns automatically satisfies the constraint. However, two rows that contain nulls for one or more key columns and the same combination of values for the other key columns violate the constraint."

I think this last statement is the one that applies to your situation. Also note that ORACLE does create an index on the columns of a unique key, just as with a primary key.

On 28 Jan 1998 22:18:32 GMT, "Dave Morse" <davemorse_at_kih.net> wrote:

>I'm creating a table that will contain 3 key fields. However, there is a
>potential that one of these key fields may, at some time, contain a null
>value. How does Oracle react to passing a null value to a key field?
>
>Thanks!!
>
>Dave Morse
>Cooper Tire & Rubber Company
>606-497-9600 x.2281
>davemorse_at_kih.net
Received on Thu Jan 29 1998 - 00:00:00 CST

Original text of this message

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