From: | Ron Johnson <ronljohnsonjr(at)gmail(dot)com> |
---|---|
To: | "pgsql-generallists(dot)postgresql(dot)org" <pgsql-general(at)lists(dot)postgresql(dot)org> |
Subject: | Re: Feature request: pg_get_tabledef(text) |
Date: | 2023-11-22 16:18:59 |
Message-ID: | CANzqJaCpuhhOEfdtRR=ZZrpMDAZcXYmc3c6BeQw_CMCJXfm+Rw@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Wed, Nov 22, 2023 at 11:09 AM Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at>
wrote:
> On Wed, 2023-11-22 at 16:41 +0100, Hans Schou wrote:
> > Similar to pg_get_viewdef() and pg_get_functiondef() it would be useful
> with a pg_get_tabledef() to get a full description of how a table is
> defined.
>
> This has been requested before:
>
> https://www.postgresql.org/message-id/flat/CAFEN2wxsDSSuOvrU03CE33ZphVLqtyh9viPp6huODCDx2UQkYA%40mail.gmail.com
>
> One of the problems is what should be included.
> Indexes? Policies? Constraints?
>
> Another problem is that while a function or view definition is a single
> SQL statement, a table definition could consist of more than a single
> statement, depending on the answer to the previous question.
>
> No unsurmountable questions, but someone would have to come up with a
> clear design and implement it.
>
Because you can already get all the other DDL relevant to creating a table
(like indices, primary and foreign keys, grants), ISTM that just a plain
CREATE TABLE with column DEFAULT clauses is what pg_get_tabledef() should
create.
A comprehensive "recreate everything related to a table" function should be
left as an exercise for the DBA.
From | Date | Subject | |
---|---|---|---|
Next Message | Atul Kumar | 2023-11-22 16:21:40 | strange behavior of pg_hba.conf file |
Previous Message | Erik Wienhold | 2023-11-22 16:18:12 | Re: Feature request: pg_get_tabledef(text) |