Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id 6F9A8B5DC73 for ; Thu, 14 Jul 2011 20:40:32 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.251]) (amavisd-maia, port 10024) with ESMTP id 41690-07 for ; Thu, 14 Jul 2011 23:40:25 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from www.postnewspapers.com.au (www.postnewspapers.com.au [173.230.139.50]) by mail.postgresql.org (Postfix) with ESMTP id CC2F2B5D91F for ; Thu, 14 Jul 2011 20:40:25 -0300 (ADT) Received: from localhost (localhost [127.0.0.1]) by www.postnewspapers.com.au (Postfix) with ESMTP id 0433E37; Thu, 14 Jul 2011 19:40:26 -0400 (EDT) X-Virus-Scanned: amavisd-new at postnewspapers.com.au.com Received: from www.postnewspapers.com.au ([127.0.0.1]) by localhost (www.postnewspapers.com.au [127.0.0.1]) (amavisd-new, port 10024) with LMTP id u1LGHih3AZs5; Thu, 14 Jul 2011 19:40:21 -0400 (EDT) Received: from mail.postnewspapers.com.au (ppp171-128.static.internode.on.net [150.101.171.128]) by www.postnewspapers.com.au (Postfix) with ESMTP id 7B97127; Thu, 14 Jul 2011 19:40:21 -0400 (EDT) Received: from localhost (localhost [127.0.0.1]) by mail.postnewspapers.com.au (Postfix) with ESMTP id 72C56AF0B4; Fri, 15 Jul 2011 07:40:20 +0800 (WST) X-Amavis-Modified: Mail body modified (using disclaimer) - mail.postnewspapers.com.au X-Virus-Scanned: Debian amavisd-new at postnewspapers.com.au Received: from mail.postnewspapers.com.au ([127.0.0.1]) by localhost (mail.postnewspapers.com.au [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 1RMsd33zOseo; Fri, 15 Jul 2011 07:40:14 +0800 (WST) Received: from [10.1.1.8] (58-7-210-8.dyn.iinet.net.au [58.7.210.8]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "Craig Ringer", Issuer "POST Certificate Authority" (verified OK)) by mail.postnewspapers.com.au (Postfix) with ESMTPSA id C2B71AF0B3; Fri, 15 Jul 2011 07:40:14 +0800 (WST) Message-ID: <4E1F7E5B.1060101@postnewspapers.com.au> Date: Fri, 15 Jul 2011 07:40:11 +0800 From: Craig Ringer User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:5.0) Gecko/20110624 Thunderbird/5.0 MIME-Version: 1.0 To: Jasen Betts CC: pgsql-sql@postgresql.org Subject: Re: Looking for a "show create table " equivalent References: <4E1C06BD.5080606@ping.de> In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.899 tagged_above=-5 required=5 tests=BAYES_00=-1.9, RP_MATCHES_RCVD=0.001 X-Spam-Level: X-Archive-Number: 201107/77 X-Sequence-Number: 35647 On 14/07/2011 6:22 PM, Jasen Betts wrote: > On 2011-07-12, B.Rathmann 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/