From: | Shaun Thomas <sthomas(at)optionshouse(dot)com> |
---|---|
To: | Chris Curvey <ccurvey(at)zuckergoldberg(dot)com>, "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: dump/restore with a hidden dependency? |
Date: | 2014-08-07 16:43:06 |
Message-ID: | 53E3AC9A.20004@optionshouse.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On 08/07/2014 10:00 AM, Chris Curvey wrote:
> I’ve done some searching and am coming up empty. Is there a way to get
> pg_restore to apply constraints AFTER loading all the tables
Kinda. PostgreSQL applies constraints with hidden system-level triggers.
An easy way to turn them off is to use this syntax:
ALTER TABLE foo DISABLE TRIGGER ALL;
Then you just need to generate one of these for each of your tables, and
run it between your table schema restore, and the data import. You can
generate a script that does it all with something like this:
COPY (
SELECT 'ALTER TABLE ' || schemaname || '.' || quote_ident(tablename)
|| ' DISABLE TRIGGER ALL;'
FROM pg_tables
) TO '/tmp/stop_triggers.sql'
After your data is loaded, just change DISABLE to ENABLE, and run the
script again.
--
Shaun Thomas
OptionsHouse, LLC | 141 W. Jackson Blvd. | Suite 800 | Chicago IL, 60604
312-676-8870
sthomas(at)optionshouse(dot)com
______________________________________________
See http://www.peak6.com/email_disclaimer/ for terms and conditions related to this email
From | Date | Subject | |
---|---|---|---|
Next Message | Bruce Momjian | 2014-08-07 16:46:14 | Re: The dangers of streaming across versions of glibc: A cautionary tale |
Previous Message | Bruce Momjian | 2014-08-07 16:43:01 | Re: Upgrading 9.0 to 9.3 - permission denied to pg_upgrade_utility.log |