Re: create definiton

From: Tom Jenkins <tjenkins(at)devis(dot)com>
To: terry(at)greatgulfhomes(dot)com
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: create definiton
Date: 2002-06-17 19:36:57
Message-ID: 1024342618.15174.196.camel@asimov
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Mon, 2002-06-17 at 12:43, terry(at)greatgulfhomes(dot)com wrote:
> Yeah, but the gotcha there is that any foreign keys are not saved as a
> FOREIGN KEY statement, just as the INSERT/UPDATE trigger that enforces the
> foreign key. So if you dump the schema, drop the table (which deletes the
> foreign keys in the foreign keyed tables), alter the dump and reload: the
> triggers to enforce the foreign key validation that reside in the tables the
> foreign key is keyed into do not get recreated, so your referential
> integrity is only enforced WRT changes to your table reloaded from the
> dump, and NOT enforced from the tables the keys go into.

I believe this is incorrect. A schema dump will include the triggers.
from my latest schema dump (this morning):
<snip>
--
-- TOC Entry ID 373 (OID 1133843)
--
-- Name: "RI_ConstraintTrigger_1133842" Type: TRIGGER Owner: tjenkins
--

CREATE CONSTRAINT TRIGGER "mandatorytraininggroupid_mandat" AFTER DELETE
ON "mandatorytraininggroup" NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH
ROW EXECUTE PROCEDURE "RI_FKey_cascade_del"
('mandatorytraininggroupid_mandat', 'mandatorytraining',
'mandatorytraininggroup', 'UNSPECIFIED', 'mandatorytraininggroupid',
'mandatorytraininggroupid');

<snip>
--
-- TOC Entry ID 460 (OID 1133543)
--
-- Name: "RI_ConstraintTrigger_1133542" Type: TRIGGER Owner: tjenkins
--

CREATE CONSTRAINT TRIGGER "educationemployee_employee_fk" AFTER UPDATE
ON "employee" NOT DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE
PROCEDURE "RI_FKey_noaction_upd" ('educationemployee_employee_fk',
'education', 'employee', 'FULL', 'educationemployee', 'employeeid');

<snip>

>
> Please correct me if I am wrong, because if there is a better way I would
> like to know, I deal with specs changing all the time and have to drop
> tables to change them from NULL to NOT NULL etc.

)
--

Tom Jenkins
Development InfoStructure
http://www.devis.com

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Robert J. Sanford, Jr. 2002-06-17 19:43:26 Re: Clients for administration?
Previous Message Dan Weston 2002-06-17 19:08:34 Re: TEXT and NULL...