Re: foreign key, create table, and transactions

Поиск
Список
Период
Сортировка
От Stephan Szabo
Тема Re: foreign key, create table, and transactions
Дата
Msg-id 20021018111126.Y26317-100000@megazone23.bigpanda.com
обсуждение исходный текст
Ответ на foreign key, create table, and transactions  (Jeffrey Green <jng15@columbia.edu>)
Список pgsql-sql
On Fri, 11 Oct 2002, Jeffrey Green wrote:

> > Hello.  I was wondering if anybody's run across the problem of
> > creating tables with foreign key constraints out of order.  What I
> > mean by this is that say I want a table called <pictures> that has a
> > foreign key reference to a table <people>.  If I define pictures
> > before table, I keep getting an error (Relation "people" doesn't
> > exist).  I tried to group them into a transaction with
> >
> > BEGIN;
> > SET CONSTRAINTS ALL DEFERRED;
> >
> > CREATE TABLE pictures...
> >
> > CREATE TABLE people...
> >
> > COMMIT;
> >
> > But still no.  Is it a requirement of postgres that all creates
> > essentially be "in order" when there are foreign key constraints?

Yes.  The check for the fact that the constraint is valid (as opposed to
the check that the data is valid) is immediate.  You can use alter table
add constraint to add the foreign key constraint after the second table
is created however.


В списке pgsql-sql по дате отправления:

Предыдущее
От: Josh Berkus
Дата:
Сообщение: Re: isAutoIncrement and Postgres
Следующее
От: Jean-Luc Lachance
Дата:
Сообщение: Re: date