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/