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: Concatenated Primary Key

Re: Concatenated Primary Key

From: Matt Brennan <mbrennan_at_gers.antispam.com>
Date: Tue, 28 Jul 1998 23:09:15 GMT
Message-ID: <01bdba7c$c251e560$049a0580@mcb>


Can you use a unique index instead? That might work...

create unique index myindex on mytable(column1, column2, column3, etc...) /

--
Matt Brennan
SQL*Tools Specialist
GERS Retail Systems
9725-C Scranton Road
San Diego, California 92121
1-800-854-2263
mbrennan_at_gers.com
(Original email address is spam-blocked.)

Mark S. Reichman <reichmanm_at_removethis.rl.af.mil.> wrote in article <35bc8854.0_at_news.rlcn.rl.af.mil>...
> In the book "Building Intelligent Databases with Oracle PL/SQL
> Triggers and Procedures" the author on page 59 says the
> individual columns of a concatenated primary key can be null as long
> as at least one of the columns is not null.
> I have found that when a concatenated primary key is created Oracle
> automatically assigns "not null" to each column.
> When I do the following I get..
>
> SQL> CREATE TABLE JUNK(X VARCHAR2(10),Y VARCHAR2(10));
>
> Table created.
>
> SQL> ALTER TABLE JUNK ADD CONSTRAINT PK_JUNK PRIMARY KEY (X,Y);
>
> Table altered.
>
> SQL> DESC JUNK
> Name Null? Type
> ------------------------------- -------- ----
> X NOT NULL VARCHAR2(10)
> Y NOT NULL VARCHAR2(10)
>
> SQL> INSERT INTO JUNK VALUES('1','A');
>
> 1 row created.
>
> SQL> INSERT INTO JUNK VALUES('1',NULL);
> INSERT INTO JUNK VALUES('1',NULL)
> *
> ERROR at line 1:
> ORA-01400: mandatory (NOT NULL) column is missing or NULL during insert
 

>
> I would like to have some of these columns null. How do I remove
> the "NOT NULL" constraint so this works like the book says...
>
> -Mark
>
>
Received on Tue Jul 28 1998 - 18:09:15 CDT

Original text of this message

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