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 1iItbK-0001fr-J7 for pgsql-general@arkaria.postgresql.org; Fri, 11 Oct 2019 12:00:54 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1iItbJ-00026H-3Z for pgsql-general@arkaria.postgresql.org; Fri, 11 Oct 2019 12:00:53 +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 1iItbI-00025o-P7 for pgsql-general@lists.postgresql.org; Fri, 11 Oct 2019 12:00:52 +0000 Received: from gandalf.net-wizard.org ([138.201.143.9]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iItbD-00048G-2Z for pgsql-general@postgresql.org; Fri, 11 Oct 2019 12:00:49 +0000 Received: from localhost (localhost [127.0.0.1]) by mail.net-wizard.org (Postfix) with ESMTP id A511B80059; Fri, 11 Oct 2019 14:00:45 +0200 (CEST) X-Virus-Scanned: Gentoo amavisd-new at aragorn Received: from aragorn.net-wizard.org ([127.0.0.1]) by localhost (aragorn.net-wizard.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id PO-o59wlcGbc; Fri, 11 Oct 2019 14:00:35 +0200 (CEST) Received: from webmail.net-wizard.org (localhost [IPv6:::1]) by gandalf.net-wizard.org (Postfix) with ESMTP id 7038D80058; Fri, 11 Oct 2019 14:00:35 +0200 (CEST) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Date: Fri, 11 Oct 2019 14:00:35 +0200 From: Charles Clavadetscher To: Sonam Sharma Cc: pgsql-general Subject: Re: Trigger In-Reply-To: References: User-Agent: Roundcube Webmail/1.4-rc1 Message-ID: <80fc8c35849c0ca641ed838c29e4e76e@swisspug.org> X-Sender: clavadetscher@swisspug.org Organization: Swiss PostgreSQL Users Group List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Hello On 2019-10-11 12:59, Sonam Sharma wrote: > Can someone please help me in how to list all the triggers with their > respective tables and the trigger body You can use the catalogs: SELECT t.tgname, t.tgrelid::regclass, t.tgfoid::regprocedure as function_name, pg_get_functiondef(t.tgfoid) as function_body FROM pg_trigger t WHERE NOT tgisinternal; There is additional information in the table such as when the trigger fire, etc. Have a look at: https://www.postgresql.org/docs/12/catalog-pg-trigger.html Another way is querying the information schema: SELECT * FROM information_schema.triggers; https://www.postgresql.org/docs/12/infoschema-triggers.html However you won't get there the function body. Regards Charles -- Charles Clavadetscher Swiss PostgreSQL Users Group Treasurer Spitzackerstrasse 9 CH - 8057 Zürich http://www.swisspug.org +---------------------------+ | ____ ______ ___ | | / )/ \/ \ | | ( / __ _\ ) | | \ (/ o) ( o) ) | | \_ (_ ) \ ) _/ | | \ /\_/ \)/ | | \/ | | _| | | | \|_/ | | | | Swiss PostgreSQL | | Users Group | | | +---------------------------+