Re: ORACLE SQL experts: please help
Date: Sun, 02 Aug 1998 23:45:02 GMT
Message-ID: <35ccf9ac.17895432_at_192.86.155.100>
you cannot create a constraint to a non-existent object -- even if it is disabled, disabling a constraint won't let you drop the other object...
In order to do what you seem to want to do, create emp and then create dept, simply:
1- create employee 2- create dept later 3- alter table employee add constraint some_name foreign key ( dnumber )references department (dnumber)
A copy of this was sent to jmohsin_at_my-dejanews.com (if that email address didn't require changing) On Sun, 02 Aug 1998 21:30:34 GMT, you 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);
>
>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
Thomas Kyte
tkyte_at_us.oracle.com
Oracle Government
Herndon VA
http://govt.us.oracle.com/ -- downloadable utilities
Opinions are mine and do not necessarily reflect those of Oracle Corporation
Anti-Anti Spam Msg: if you want an answer emailed to you, you have to make it easy to get email to you. Any bounced email will be treated the same way i treat SPAM-- I delete it. Received on Mon Aug 03 1998 - 01:45:02 CEST