Results 1 to 5 of 5
  1. #1
    Join Date
    Feb 2006

    Unhappy Unanswered: error: table or view does not exist (was "SQL")

    I am new to sql..
    Is it possible to update table constraints????using update operation.

    My question is how do i create a table in the very beginnnig which has a primary key and also has a foreign key refering to another table which does not exist currently.And similarly the chain goes on..

    because it says the table or view does not exist....

  2. #2
    Join Date
    Jun 2003
    West Palm Beach, FL

    Thumbs down

    You cannot create foreign key on a non-existent table!

    The person who says it can't be done should not interrupt the person doing it. -- Chinese proverb

  3. #3
    Join Date
    Nov 2004
    out on a limb
    Provided Answers: 59
    LKBrown is correct, the way round the problem is to create the tables from the top down (ie create the tables with no foreign key contraints first, then create the tables that have foreign key contstraints. Failing that create your tables then retrospectively apply the foreign key constraints.

    Alternatively consider using a data modelling tool to create your table design, and let it handle the hierarchy.
    I'd rather be riding on the Tiger 800 or the Norton

  4. #4
    Join Date
    Feb 2004
    In front of the computer
    Provided Answers: 54
    I usually create my tables in one pass, my primary keys in a second pass (using ALTER TABLE), then my foreign keys in a third pass (also using ALTER TABLE). That gets around all kinds of nasty problems like this.


  5. #5
    Join Date
    Sep 2002
    Provided Answers: 1
    In Oracle (and your error message "table or view does not exist" makes me believe this is Oracle) you can also use the "CREATE SCHEMA" syntax to put all you table creation into a single transaction:
    create schema authorization user1
      create table t1 (a int primary key, b int references t2(b))
      create table t2 (b int primary key, a int references t1(a));

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts