pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Craig Ringer <craig@postnewspapers.com.au>
To: Jasen Betts <jasen@xnet.co.nz>
Cc: pgsql-sql@postgresql.org
Subject: Re: Looking for a "show create table <name>" equivalent
Date: Fri, 15 Jul 2011 07:40:11 +0800
Message-ID: <4E1F7E5B.1060101@postnewspapers.com.au> (raw)
In-Reply-To: <ivmg0m$2ip$1@reversiblemaps.ath.cx>
References: <4E1C06BD.5080606@ping.de>
	<ivmg0m$2ip$1@reversiblemaps.ath.cx>

On 14/07/2011 6:22 PM, Jasen Betts wrote:
> On 2011-07-12, B.Rathmann<B.Rathmann@ping.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/



view thread (6+ messages)

Message-ID: <4E1F7E5B.1060101@postnewspapers.com.au>
Permalink:  ../4E1F7E5B.1060101@postnewspapers.com.au/
Also on:    postgresql.org/message-id/4E1F7E5B.1060101@postnewspapers.com.au

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: craig@postnewspapers.com.au, jasen@xnet.co.nz
  Subject: Re: Looking for a "show create table <name>" equivalent
  In-Reply-To: <4E1F7E5B.1060101@postnewspapers.com.au>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox