Re: REFERENCES constraint
От | Stephan Szabo |
---|---|
Тема | Re: REFERENCES constraint |
Дата | |
Msg-id | Pine.BSF.4.21.0108081111280.40255-100000@megazone23.bigpanda.com обсуждение исходный текст |
Ответ на | REFERENCES constraint (Cedar Cox <cedarc@visionforisrael.com>) |
Список | pgsql-sql |
On Wed, 8 Aug 2001, Cedar Cox wrote: > > Two questions (maybe they are silly..) > > 1. Can a column reference more than one table? (This assumes you use a > single sequence to generate the IDs for both "tbla" and "tblb". I guess > you would also have the problem of enforcing a unique index. Say what?! > A unique index across multiple tables.. absurd :) eg.. > > CREATE TABLE blah ( > id int4, > f_id int4 REFERENCES tbla (id) REFERENCES tblb (id) > ) Yes, you should be able to do this, but it won't do what you want, it'll make it be required in both tables. You'll need to do this one by hand. > 2. Can a column reference another column in the same table? eg.. > > CREATE TABLE bloo ( > id int4, > p_id int4 REFERENCES bloo (id) > -- or > --p_id int4 REFERENCES (id) > ) Yes, using your first syntax that should work.
В списке pgsql-sql по дате отправления: