Re: get column default value
От | Rick Morris |
---|---|
Тема | Re: get column default value |
Дата | |
Msg-id | 4558AA88.3070102@brainscraps.com обсуждение исходный текст |
Ответ на | get column default value (Jean-Christophe Roux <jcxxr@yahoo.com>) |
Список | pgsql-php |
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
В списке pgsql-php по дате отправления: