Re: Oracle command

From: Lee Miller <lpm_at_newsguy.com>
Date: Wed, 7 Feb 2001 15:09:57 -0500
Message-ID: <95sa2p02l2l_at_enews3.newsguy.com>


Matthew wrote in message <95qokd$lh8$1_at_bunyip.cc.uq.edu.au>...
>Hi,
>
>I am a novice in Oracle SQL.
>I was taught to use the following SQL to create table and its key
>constraints
>"CREATE TABLE EMPLOYEE
>(ID CHAR(9) NOT NULL,
>NAME CHAR(40) NOT NULL,
>...
>CONSTRAINT EMPPK
> PRIMARY KEY (ID),
>CONSTRAINT EMPFK
> FOREIGN KEY (NAME) REFERENCES
>DEPARTMENT_TABLE(NAME));"
>
>I will like to ask the following the questions:
>1. What is the use of naming the constraints, ie, naming the primary key
 and
>foreign key? How do I make use of them?

It makes it easier to figure out what they are for by looking at the constraint name

>2. What is the Oracle command for listing the constraints? I tried
>"DESCRIBE" but it does not give me all the useful information that I want.

SELECT constraint_name FROM user_constraints WHERE table_name = 'EMPLOYEE'; Received on Wed Feb 07 2001 - 21:09:57 CET

Original text of this message