Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pe1UF-0007bd-T8 for pgsql-admin@arkaria.postgresql.org; Sun, 19 Mar 2023 22:26:47 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1pe1UE-0002Ck-Oz for pgsql-admin@arkaria.postgresql.org; Sun, 19 Mar 2023 22:26:46 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pe1UE-0002Cb-EB for pgsql-admin@lists.postgresql.org; Sun, 19 Mar 2023 22:26:46 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pe1UB-00028u-Vf for pgsql-admin@postgresql.org; Sun, 19 Mar 2023 22:26:45 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 32JMQfZG803988; Sun, 19 Mar 2023 18:26:42 -0400 From: Tom Lane To: richard coleman cc: pgsql-admin Subject: Re: PostgreSQL equivalents to dbms_metadata.get_ddl & dbms_metadata.get_dependent_ddl In-reply-to: References: Comments: In-reply-to richard coleman message dated "Sun, 19 Mar 2023 17:36:17 -0400" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <803986.1679264801.1@sss.pgh.pa.us> Date: Sun, 19 Mar 2023 18:26:41 -0400 Message-ID: <803987.1679264801@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk richard coleman writes: > I am trying to find a simple way to get access the DDL information for > PostgreSQL tables, constraints, and indices via SQL. There are bits of that, but it's not terribly complete or consistent because nobody's made a concerted effort to build stuff that wasn't driven by "what does pg_dump need". (And what pg_dump needs, for the most part, is not simply "give me all the DDL for this object in a black box".) I'd suggest taking a look at the pg_get_* functions, which are mostly documented at https://www.postgresql.org/docs/current/functions-info.html There are some other things on that page that might help, too. regards, tom lane