Re: weird(to me) request
От | Larry Rosenman |
---|---|
Тема | Re: weird(to me) request |
Дата | |
Msg-id | 324780000.1064517413@lerlaptop-red.iadfw.net обсуждение исходный текст |
Ответ на | Re: weird(to me) request (Richard Huxton <dev@archonet.com>) |
Список | pgsql-sql |
--On Thursday, September 25, 2003 20:09:35 +0100 Richard Huxton <dev@archonet.com> wrote: > On Thursday 25 September 2003 19:51, Larry Rosenman wrote: >> I have the following rows (in addition to others): >> >> acct_num text, >> master_acct_num text, >> >> >> These are in the same table. >> >> What I want to enforce is that if the master_acct_num field is NOT NULL >> (it can be NULL, and >> that's fine), that the value appears in some row as acct_num. acct_num >> has a unique index on it, so that's fine. >> >> I'm not sure how to do this.... > > ALTER TABLE my_table ADD CONSTRAINT my_self_fk FOREIGN KEY > (master_acct_num) REFERENCES my_table (acct_num); > > It's really just a foreign-key to yourself I wasn't sure I could do that. Thanks! LER -- Larry Rosenman http://www.lerctr.org/~ler Phone: +1 972-414-9812 E-Mail: ler@lerctr.org US Mail: 1905 Steamboat Springs Drive, Garland, TX 75044-6749
В списке pgsql-sql по дате отправления: