Feature request: pg_get_tabledef(text) - Mailing list pgsql-general

From Hans Schou
Subject Feature request: pg_get_tabledef(text)
Date
Msg-id CAApBw37LEQoFcDSWFmK_Xh=OfUVPeCqOxXn-sHBYYCbtsequLg@mail.gmail.com
Whole thread Raw
Responses Re: Feature request: pg_get_tabledef(text)
Re: Feature request: pg_get_tabledef(text)
Re: Feature request: pg_get_tabledef(text)
List pgsql-general
Hi

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.

Currently the table definition can be extracted with the command:

  pg_dump -d foo --schema-only --table=bar | egrep '^[^-]'

The psql command '\d bar' gives some of the same information but it is not in a format where it can be used to create a table.

Extra:
With the pg_get_tabledef() function in place it is very close to be possible to implement pg_dump() within the system. So instead of running:
  pg_dump -d foo
one could just run:
  psql -d foo -c 'SELECT pg_dump()'

The function could also be called from within a programming language like Java/PHP.

pg_dump has a lot of options where some of them could be parameters to the pg_dump() function. If using a cloud or other webservice this will be an easy way to make an extra backup.

--
𝕳𝖆𝖓𝖘 𝕾𝖈𝖍𝖔𝖚
☏ ➁➁ ➅➃ ➇⓪ ➁⓪

pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: Removing oids with pg_repack
Next
From: Ron Johnson
Date:
Subject: Re: Feature request: pg_get_tabledef(text)