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 1oAc0r-0001Sq-Cw for pgsql-general@arkaria.postgresql.org; Sun, 10 Jul 2022 18:50:37 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1oAc0o-00057u-3A for pgsql-general@arkaria.postgresql.org; Sun, 10 Jul 2022 18:50:34 +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 1oAc0n-00057l-Nd for pgsql-general@lists.postgresql.org; Sun, 10 Jul 2022 18:50:33 +0000 Received: from mail-qk1-x72d.google.com ([2607:f8b0:4864:20::72d]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1oAc0j-0006mP-P6 for pgsql-general@lists.postgresql.org; Sun, 10 Jul 2022 18:50:32 +0000 Received: by mail-qk1-x72d.google.com with SMTP id o26so2531219qkl.6 for ; Sun, 10 Jul 2022 11:50:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:date:mime-version:user-agent:subject:content-language:to :references:from:in-reply-to; bh=ijBGBE8zEN+xigaGqw6cm4grEKhS2JgntTte1W2RaIM=; b=ZwAyWl3CKcc8Awf+haVzcE4GTt9btiZiOxiaagEUybaj7/KIvQMFUi6X8foSPoi1CS x6HR03ObDPRW+J1PrFQe7QQcCYIJesOORT7krT+rnW6P4/ihkr+5kULT9YZ3JNQ14TG0 /N0dyrH9ostmDUu2/WKagfTedz19N7wCQVKGa0ZUTq9M1u4GQspz0eFHdgyrs6JEBg6v eZiN67M/qbsPhYSntfpH58OowLWc2GEr9QSdoWUqYl1Atf2/ybNKWjtH6P5sGOB12wwk KBonrd0/TLv14hKR6W6TLS+8I4ru+strm2/KKuuEDSbKxs9G26B4kYBQFPC8Wg/HCShn dTTg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:references:from:in-reply-to; bh=ijBGBE8zEN+xigaGqw6cm4grEKhS2JgntTte1W2RaIM=; b=jPPfCwfEFTcXVhdVbvnb33jTCDbwiy1d0nNf/VXMoVKvl0Uxj465Pn0tMagKHUSoGr E7NCXPeQvaDHJyU1LazRc1313CyILoNOoijqyTT5z+kdkPyYUIVgwqba/33I9aKQA1IV plY0SogYm4j1haE9VVFKEPFZJOsoZLKE55L4ZyLRm/pyUdZP82DuAlSm8cci9zqoFkyi bxHA211t/M3D0HixjEeZodgolVcIQNJvcQS6r2A7SlpDfYeTsH7lOroloHIvUj8PY9X/ nlYCjapxKEwTTky+HnfJjG4KHYNxn67lrScQHosSxnRph6m472UtfOLSSiJ3yVdh+5Lz s1hw== X-Gm-Message-State: AJIora+TYf3caUiHb7ehNi/Sg+xz24pLdan3zVPHGfU89INt0y2Xn3N9 bCr8TMUIyBtKW5vLrVU4/16ylUDmxOIebA== X-Google-Smtp-Source: AGRyM1vH6mJ04f4/kIf+BMke1banqgCd+a+AcyZg3Q2QL4gqGT7qnEWIGiJ02yNrn9H23nmOU8beHw== X-Received: by 2002:a05:620a:244d:b0:6b2:538f:ffda with SMTP id h13-20020a05620a244d00b006b2538fffdamr9087808qkn.218.1657479028521; Sun, 10 Jul 2022 11:50:28 -0700 (PDT) Received: from [192.168.2.100] (pool-72-79-19-93.nwrknj.east.verizon.net. [72.79.19.93]) by smtp.gmail.com with ESMTPSA id z11-20020ac87f8b000000b0031ea864d3b2sm4057362qtj.30.2022.07.10.11.50.27 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 10 Jul 2022 11:50:28 -0700 (PDT) Content-Type: multipart/alternative; boundary="------------kFCUi0XBDGZbn7sedHkY01vJ" Message-ID: Date: Sun, 10 Jul 2022 14:50:27 -0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.11.0 Subject: Re: Get the table creation DDL Content-Language: en-US To: pgsql-general@lists.postgresql.org References: From: Mladen Gogala In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk This is a multi-part message in MIME format. --------------kFCUi0XBDGZbn7sedHkY01vJ Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit On 7/10/22 13:57, Michael Nolan wrote: > I do not know those other tools, but there should be documentation for > them, as there is in the man page for how to process just one table > using pg_dump.   You can pipe the output of pg_dump directly to psql, > but I find that's seldom useful. > -- > Mike Nolan There is an extension which does precisely what you need: https://github.com/MichaelDBA/pg_get_tabledef In my opinion, that is a little inconsistency on the part of the maintainers part because there are functions pg_get_functiondef, pg_get_indexdef and pg_get_viewdef  but nothing for tables. https://www.postgresql.org/docs/14/functions-info.html -- Mladen Gogala Database Consultant Tel: (347) 321-1217 https://dbwhisperer.wordpress.com --------------kFCUi0XBDGZbn7sedHkY01vJ Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 8bit
On 7/10/22 13:57, Michael Nolan wrote:
I do not know those other tools, but there should be documentation for them, as there is in the man page for how to process just one table using pg_dump.   You can pipe the output of pg_dump directly to psql, but I find that's seldom useful.
--
Mike Nolan

There is an extension which does precisely what you need:

https://github.com/MichaelDBA/pg_get_tabledef

In my opinion, that is a little inconsistency on the part of the maintainers part because there are functions pg_get_functiondef, pg_get_indexdef and pg_get_viewdef  but nothing for tables.

https://www.postgresql.org/docs/14/functions-info.html

-- 
Mladen Gogala
Database Consultant
Tel: (347) 321-1217
https://dbwhisperer.wordpress.com
--------------kFCUi0XBDGZbn7sedHkY01vJ--