Re: ORACLE SQL experts: please help

From: Joel R. Kallman <jkallman_at_us.oracle.com>
Date: Mon, 03 Aug 1998 00:33:55 GMT
Message-ID: <35c504a5.4882050_at_newshost.us.oracle.com>


On Sun, 02 Aug 1998 21:30:34 GMT, jmohsin_at_my-dejanews.com wrote:

>Hi,
>
>I had a rather simple question pertaining to "create table". I am unable
>to DISABLE a constraint that refers to a yet-to-be-created table.
>
>In the SQL below, I am trying to create a table called "EMPLOYEE" that has a
>foreign key from a currently non-existant table called DEPARTMENT. Because
>DEPARTMENT does not exist, I am trying to use the DISABLE clause for
>CONSTRAINT FK_DEP. The idea is that I will create DEPARTMENT later and then
>ENABLE the FK_DEP constraint.
>
>I get the following error:
>CONSTRAINT FK_DEP FOREIGN KEY (DNO) REFERENCES DEPARTMENT(DNUMBER) DISABLE)
> *
>ERROR at line 8:
>ORA-00942: table (DEPARTMENT) or view does not exist
>
>
>Here is the SQL I used:
>CREATE TABLE EMPLOYEE (
>FULLNAME VARCHAR2(15),
>LASTNAME VARCHAR2(15),
>SSN CHAR(9) NOT NULL,
>ADDRESS VARCHAR2(30),
>DNO INT NOT NULL,
>CONSTRAINT PK_EMP PRIMARY KEY(SSN) DISABLE,
>CONSTRAINT FK_DEP FOREIGN KEY (DNO) REFERENCES DEPARTMENT(DNUMBER) DISABLE);
Just simply break out the foreign key definition into a separate statement, as in:

CREATE TABLE EMPLOYEE (
FULLNAME VARCHAR2(15),
LASTNAME VARCHAR2(15),
SSN CHAR(9) NOT NULL,
ADDRESS VARCHAR2(30),
DNO INT NOT NULL,
CONSTRAINT PK_EMP PRIMARY KEY(SSN)); <<Create DEPARTMENT table here>>

ALTER TABLE EMPLOYEE
  ADD CONSTRAINT fk_dep FOREIGN KEY (dno)   REFERENCES department (dnumber);

>
>Please post responses here.
>
>
>-----== Posted via Deja News, The Leader in Internet Discussion ==-----
>http://www.dejanews.com/rg_mkgrp.xp Create Your Own Free Member Forum

Thanks!

Joel

Joel R. Kallman Oracle Government, Education, & Health

Columbus, OH                             http://govt.us.oracle.com
jkallman_at_us.oracle.com                   http://www.oracle.com



The statements and opinions expressed here are my own and do not necessarily represent those of Oracle Corporation. Received on Mon Aug 03 1998 - 02:33:55 CEST

Original text of this message