Re: Looking for a "show create table <name>" equivalent

From: Craig Ringer <craig(at)postnewspapers(dot)com(dot)au>
To: Jasen Betts <jasen(at)xnet(dot)co(dot)nz>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: Looking for a "show create table <name>" equivalent
Date: 2011-07-14 23:40:11
Message-ID: 4E1F7E5B.1060101@postnewspapers.com.au
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

On 14/07/2011 6:22 PM, Jasen Betts wrote:
> On 2011-07-12, B.Rathmann<B(dot)Rathmann(at)ping(dot)de> wrote:
>> Hello,
>>
>> I've been trying to find out how to find out which sql was run to create
>> a certain table.
>
> That's like trying to find what change was used to create $1.83

Yep, and just like that question, sometimes any valid answer is fine.
You might not care if it's $1 + .5 + .2 + .02 + .01 or 183 * 0.01, so
long as the result is the same.

This is turning out to be a reasonably common question, where people
want to be able to use functionality of pg_dump from _within_ the
database system.

If the INFORMATION_SCHEMA isn't sufficient for the OP's purposes or is
too clumsy for re-creating DDL from, there's another option. It's ugly,
but you can add a plpythonu or plperlu server-side function that calls
the server's copy of pg_dump and spits the resulting text back to the
client.

--
Craig Ringer

POST Newspapers
276 Onslow Rd, Shenton Park
Ph: 08 9381 3088 Fax: 08 9388 2258
ABN: 50 008 917 717
http://www.postnewspapers.com.au/

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Thomas Kellerer 2011-07-18 08:22:51 to_char() accepting invalid dates?
Previous Message Oliveiros d'Azevedo Cristina 2011-07-14 11:30:40 Re: [NOVICE] Compare rows