From: | Michael Fuhr <mike(at)fuhr(dot)org> |
---|---|
To: | sarlav kumar <sarlavk(at)yahoo(dot)com> |
Cc: | pgsqlnovice <pgsql-novice(at)postgresql(dot)org> |
Subject: | Re: FK relationships |
Date: | 2005-01-12 20:42:10 |
Message-ID: | 20050112204209.GA96304@winnie.fuhr.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-novice |
On Wed, Jan 12, 2005 at 12:07:16PM -0800, sarlav kumar wrote:
> $1 FOREIGN KEY (uid) REFERENCES customer(id) ON UPDATE NO ACTION ON DELETE NO ACTION
>
> Since $1 is not very clear about the FK relationship that exists
> between the tables, I would like to rename these, or be able to get
> the names of the colums that are FK on customer table.
The constraint description shows the columns: uid in the referencing
table and id in the referenced table. If you want to rename a
constraint, then use ALTER TABLE to drop it and add it back with a
meaningful name:
ALTER TABLE customer_facts DROP CONSTRAINT "$1";
ALTER TABLE customer_facts ADD CONSTRAINT customer_facts_uid_fkey
FOREIGN KEY (uid) REFERENCES customer(id);
See the ALTER TABLE documentation for more information. You might
want to make these changes inside a transaction to avoid race
conditions with other sessions.
In 8.0 a constraint's default name will be table_column_type, so
instead of $1 you'll get customerdata_uid_fkey, etc.
--
Michael Fuhr
http://www.fuhr.org/~mfuhr/
From | Date | Subject | |
---|---|---|---|
Next Message | sarlav kumar | 2005-01-12 21:01:17 | Re: FK relationships |
Previous Message | sarlav kumar | 2005-01-12 20:07:16 | Re: FK relationships |