Received: from localhost (uranus.hub.org [200.46.204.60]) by postgresql.org (Postfix) with ESMTP id B0A2D9FB20F for ; Mon, 13 Nov 2006 11:23:01 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.60]) (amavisd-new, port 10024) with ESMTP id 83964-03 for ; Mon, 13 Nov 2006 11:22:57 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey- Received: from imf25aec.mail.bellsouth.net (imf25aec.mail.bellsouth.net [205.152.59.73]) by postgresql.org (Postfix) with ESMTP id 034019FB1F2 for ; Mon, 13 Nov 2006 11:22:56 -0400 (AST) Received: from ibm69aec.bellsouth.net ([65.3.167.212]) by imf25aec.mail.bellsouth.net with ESMTP id <20061113152255.FTS2981.imf25aec.mail.bellsouth.net@ibm69aec.bellsouth.net> for ; Mon, 13 Nov 2006 10:22:55 -0500 Received: from [192.168.1.5] (really [65.3.167.212]) by ibm69aec.bellsouth.net with ESMTP id <20061113152250.VJBM21497.ibm69aec.bellsouth.net@[192.168.1.5]>; Mon, 13 Nov 2006 10:22:50 -0500 Message-ID: <4558AA88.3070102@brainscraps.com> Date: Mon, 13 Nov 2006 12:25:28 -0500 From: Rick Morris User-Agent: Thunderbird 1.5.0.5 (X11/20060904) MIME-Version: 1.0 To: Jean-Christophe Roux CC: pgsql-php@postgresql.org Subject: Re: get column default value References: <20061113144914.83394.qmail@web35307.mail.mud.yahoo.com> In-Reply-To: <20061113144914.83394.qmail@web35307.mail.mud.yahoo.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200611/45 X-Sequence-Number: 3662 Jean-Christophe Roux wrote: > Hello, > How can I get the default value for a column? > To change the default value, something like > ALTER TABLE dummy ALTER COLUMN value SET DEFAULT -12; > would do the job, but how could I query the value? > > > Thanks in advance > You can select from the pg_ system tables, but there is now an easier method with PostgreSQL 7.4+. What you want is the (redundantly-named) "information_schema" schema in any PostgreSQL database. I take it you have installed phpPgAdmin (phppgadmin.sf.net)? Then just open it and navigate to information_schema inside your database, and look for the View titled 'columns', and a column titled 'column_default'. So your query would look something like: SELECT column_default FROM information_schema.columns WHERE table_name='your_table_name'; or if needed: SELECT column_default FROM information_schema.columns WHERE table_name='your_table_name' AND schema='whatever_schema'; (this would be needed if you have a duplicate table name in more than one schema) HTH, Regards, Rick Morris