Why can't I create two tables that are foreign keys for each other?

From: Eric Du <duxy(at)leyou(dot)com>
To: pgsql <pgsql-general(at)hub(dot)org>
Subject: Why can't I create two tables that are foreign keys for each other?
Date: 2000-06-22 10:43:34
Message-ID: 3951EDD6.FB29F9DE@leyou.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Here is my sql script to create two tables that are foreign keys for
each other.

BEGIN;
CREATE TABLE t1 (
id serial PRIMARY KEY,
t2_id integer REFERENCES t2 INITIALLY DEFERRED
);
CREATE TABLE t2 (
id serial PRIMARY KEY,
t1_id integer REFERENCES t1 INITIALLY DEFERRED
);
END;

psql complains the following:
ERROR: Relation 't2' does not exist
ERROR: Relation 't1' does not exist

What's the matter?

Thanks in advance,

--
Eric Du
-----------------------------------
Tel: (86-010) 64181818-821
Fax: (86-010) 64181385
Leyou WebSite: http://www.leyou.com

Browse pgsql-general by date

  From Date Subject
Next Message Robert D. Nelson 2000-06-22 12:05:00 RE: Postgres with php3
Previous Message Denis Perchine 2000-06-22 08:05:34 Re: [GENERAL] libpq error codes