Help converting constraint triggers

From: Chris Hoover <revoohc(at)gmail(dot)com>
To: pgsql-admin(at)postgresql(dot)org
Subject: Help converting constraint triggers
Date: 2005-08-03 15:27:30
Message-ID: 1d219a6f05080308271131c8d9@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

I need some help understanding how to convert constraint triggers to
normal foreign keys. I have several of them in my database that a
previous dba created. Since they don't show up in most PostgreSQL
tools, they are becoming a real pain to deal with.

Here is an example of on of the constraint triggers:
CREATE CONSTRAINT TRIGGER sys_user_group_id_fkey
AFTER INSERT OR UPDATE ON sys_user
FROM sys_group
NOT DEFERRABLE INITIALLY IMMEDIATE
FOR EACH ROW
EXECUTE PROCEDURE "RI_FKey_check_ins" ('sys_user_group_id_fkey',
'sys_user', 'sys_group', 'UNSPECIFIED', 'group_id', 'group_id');

I believe this is the same as the foriegn key definition,

alter table sys_user
add constraint sys_user_group_id_fkey foreign key(group_id)
references sys_group(group_id)
not deferrrable;

Is this correct? If not, how would be proper foreign key be defined?

Thanks,

Chris

Responses

Browse pgsql-admin by date

  From Date Subject
Next Message Tom Lane 2005-08-03 15:53:21 Re: Help converting constraint triggers
Previous Message Guido Barosio 2005-08-03 15:08:21 Re: Blocking connection and timeout problem