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

Concatenated Primary Key

From: Mark S. Reichman <reichmanm_at_removethis.rl.af.mil.>
Date: 27 Jul 98 14:01:56 GMT
Message-ID: <35bc8854.0@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 Mon Jul 27 1998 - 09:01:56 CDT

Original text of this message

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