Adding Foreign Key constraints outside of table def.

From: Mike Haberman <mikeh(at)ncsa(dot)uiuc(dot)edu>
To: pgsql-general(at)postgresql(dot)org
Cc: Mike Haberman <mikeh(at)ncsa(dot)uiuc(dot)edu>
Subject: Adding Foreign Key constraints outside of table def.
Date: 2001-06-22 13:54:53
Message-ID: 20010622085453.A57556@ncsa.uiuc.edu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


Hello all,

I need to add foreign key support outside of the table via the
CREATE CONSTRAINT TRIGGER .. command.

1. Is there a way to add it without worrying about the
syntax of "RI_FKey_..()" e.g. (this would be nice if it worked)

ADD CONSTRAINT $fk.LocalColumnNames FOREIGN KEY ($fk.LocalColumnNames)
REFERENCES $fk.ForeignTableName ($fk.ForeignColumnNames)
ON DELETE set null, ON UPDATE cascade;

2. assuming no for #1 (the on delete and on update is not accepted)
I need to do the following:

CREATE CONSTRAINT TRIGGER "<unnamed>" AFTER UPDATE ON "teamowner"
NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE PROCEDURE
"RI_FKey_cascade_upd" ('<unnamed>', 'league', 'teamowner', 'UNSPECIFIED', ' leagueownerid', 'id');

The problem is that I am unable to remove the trigger <unnamed>

drop trigger name on table does not work.
I tried "unnamed", "<unnamed>"

I need to drop the triggers in case I reload the same schema.

3. If I drop a table, how come the constainsts for that
table are NOT dropped as well?

4. for circular references,
Table A references B
B references C
C references A

is it impossible to do an insert (assuming all the foreign key
constraints are set up) ?

thanks

mike

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Lamar Owen 2001-06-22 15:30:44 Re: Re: Authentication
Previous Message Tom Lane 2001-06-22 13:44:14 Re: Re: Authentification