Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gSFDn-0002gS-HQ for pgsql-general@arkaria.postgresql.org; Thu, 29 Nov 2018 05:50:43 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gSFDm-0005O0-8f for pgsql-general@arkaria.postgresql.org; Thu, 29 Nov 2018 05:50:42 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gSFDm-0005Nq-0g for pgsql-general@lists.postgresql.org; Thu, 29 Nov 2018 05:50:42 +0000 Received: from mx2a.mailbox.org ([2001:67c:2050:104:0:2:25:2] helo=mx2.mailbox.org) by magus.postgresql.org with esmtps (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gSFDj-0003XW-IM for pgsql-general@postgresql.org; Thu, 29 Nov 2018 05:50:41 +0000 Received: from smtp2.mailbox.org (unknown [IPv6:2001:67c:2050:105:465:1:2:0]) (using TLSv1.2 with cipher ECDHE-RSA-CHACHA20-POLY1305 (256/256 bits)) (No client certificate requested) by mx2.mailbox.org (Postfix) with ESMTPS id 93D3BA1112; Thu, 29 Nov 2018 06:50:37 +0100 (CET) X-Virus-Scanned: amavisd-new at heinlein-support.de Received: from smtp2.mailbox.org ([80.241.60.241]) by spamfilter04.heinlein-hosting.de (spamfilter04.heinlein-hosting.de [80.241.56.122]) (amavisd-new, port 10030) with ESMTP id MESyHL3M4K1r; Thu, 29 Nov 2018 06:50:36 +0100 (CET) Message-ID: Subject: Re: Triggers when importing data From: Laurenz Albe To: Sathish Kumar , pgsql-general@postgresql.org Date: Thu, 29 Nov 2018 06:50:35 +0100 In-Reply-To: References: Organization: Cybertec Content-Type: text/plain; charset="UTF-8" Mime-Version: 1.0 Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Sathish Kumar wrote: > I am trying to export and import sql file of a database. I would like to know > whether it will execute all the triggers when importing the sql dump which > is for Insert or Update or Delete. > > Export:pg_dump -h test -U db_admin --format=plain --no-owner --no-acl production | sed -E 's/(DROP|CREATE|COMMENT ON) EXTENSION/-- \1 EXTENSION/g' > test.sql > > Import: psql -h test -U db_admin -d production -W < test.sql That will call all triggers on tables that have no primary key or unique constraints. On all other tables, that will give you a constraint violation because the same rows are already in the table... What are you trying to achieve? Yours, Laurenz Albe -- Cybertec | https://www.cybertec-postgresql.com