Re: DDL problems

From: Thomas Kyte <tkyte_at_us.oracle.com>
Date: Fri, 26 Mar 1999 02:28:02 GMT
Message-ID: <36feef7a.4242089_at_192.86.155.100>


A copy of this was sent to "Gennady" <gennadyb_at_halcosoftware.com> (if that email address didn't require changing) On Thu, 25 Mar 1999 11:22:58 -0800, you wrote:

>Hello,
>I’ve got problems:
>1. When I created a table’s primary key this constraint does not implicitly
>creates NOT NULL and UNIQUE constraints on the table.
>2. I can not create a foreign key on composite primary key. The only way is
>to split composite key on single field constraints, for example, instead of:
>Constraint FK_LbrGroup_LSizes foreign key(LGroups,LbrGroup) references
>LumberGroups(LGroups,LbrGroup)
>
>I need create:
>Constraint FK_LGroups_LSizes foreign key(LGroups) references
>LumberGroups(LGroups),
>Constraint FK_LbrGroup_LSizes foreign key(LbrGroup) references
>LumberGroups(LbrGroup)
>
>Could you explain me the reasons ?

can you post your DDL? I just ran this:

SQL> create table parent( x int, y int, primary key(x,y) );

Table created.

SQL> desc parent

 Name                            Null?    Type
 ------------------------------- -------- ----
 X                               NOT NULL NUMBER(38)
 Y                               NOT NULL NUMBER(38)


SQL> create table child ( x int, y int, foreign key(x,y) references parent(x,y) );

Table created.

SQL>
SQL> select table_name, constraint_type
  2 from user_constraints where table_name in ( 'PARENT', 'CHILD' );

TABLE_NAME                     C
------------------------------ -
CHILD                          R
PARENT                         P

it doesn't create explicit NOT NULL constraints on the table (the columns are NOT NULL) and a primary key constraint creates a unique index -- not a unique constraint.

>Thank you,
>Gennady
>
>
>
 

Thomas Kyte
tkyte_at_us.oracle.com
Oracle Service Industries
Reston, VA USA

--
http://govt.us.oracle.com/    -- downloadable utilities
 
----------------------------------------------------------------------------
Opinions are mine and do not necessarily reflect those of Oracle Corporation
Received on Fri Mar 26 1999 - 03:28:02 CET

Original text of this message