Re: Restore - disable triggers - when they fired?

From: Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>
To: Durumdara <durumdara(at)gmail(dot)com>
Cc: Postgres General <pgsql-general(at)postgresql(dot)org>
Subject: Re: Restore - disable triggers - when they fired?
Date: 2018-03-21 13:16:34
Message-ID: 8b75c8bb-e5a5-47eb-0cc6-477a90a8a7cc@aklaver.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 03/21/2018 02:41 AM, Durumdara wrote:
> Dear Adrian!
>
> 2018-03-20 16:33 GMT+01:00 Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com
> <mailto:adrian(dot)klaver(at)aklaver(dot)com>>:
>
> On 03/20/2018 07:56 AM, Durumdara wrote:
>
>
> pg_dump --disable-triggers -d test -U aklaver -t
> disable_trigger_test -a -f disable_trigger_test_data.sql
>
>
> CREATE OR REPLACE FUNCTION public.trigger_test()
> ...
> truncate disable_trigger_test ;
>
> #Note I do this as a superuser.
> psql -d test -U postgres -f disable_trigger_test_data.sql
>
> test=> select * from disable_trigger_test ;
>  id | fld_1
> ----+-------
>   1 | dog
>   2 | cat
>
>
> Thank you! Now I got it!
> So the difference is:
>
> 1.) FULL DB restore into empty database creates the extra objects at the
> end, so I do not need to worry about triggers.

This also holds if you do a single(or multiple) table restore of both
the table schema and data at the same time.

>
> 2.) Partial data restore into an existing database to existing tables
> with triggers: this point I need to set "disable triggers" option.

Well partial or complete data restore, anything that will trip the
triggers on an existing table.

> Very-very thank you!

Glad it helped.

>
> dd

--
Adrian Klaver
adrian(dot)klaver(at)aklaver(dot)com

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Battuello, Louis 2018-03-21 15:00:06 Foreign Key Validation after Reference Table Ownership Change
Previous Message Adrian Klaver 2018-03-21 13:02:17 Re: postgresql-10.3 on unbuntu-17.10 - how??