Skip site navigation (1) Skip section navigation (2)

Peripheral Links

Header And Logo

PostgreSQL
| The world's most advanced open source database.

Site Navigation

Search for
  Advanced Search

Re: get column default value



I understand that but I need to build an interface so that my user can change the default values of some table/columns. So I need a way to query the current default value to show the user what it is currently. For instance, let's say I have a table products and there is a column price and the default price is $199, I'd like to get that $199 and give my user the opportunity to update that value. The column does not have any sequence attached to it.
JCR

----- Original Message ----
From: Ketema Harris <ketema(at)gmail(dot)com>
To: Jean-Christophe Roux <jcxxr(at)yahoo(dot)com>
Cc: pgsql-php(at)postgresql(dot)org
Sent: Monday, November 13, 2006 9:59:29 AM
Subject: Re: [PHP] get column default value

The default value for a column is just that the value you say is default.  It only come into play when you do an insert into the table.  If you do not provide a value for that column then your default value is entered.

Now if you set the default value of a column to a sequence, then you can manage the sequence using the sequence functions: currval, nextval, and setval.  Sequences and their functions are documented in the pg manual.

On Nov 13, 2006, at 9:49 AM, 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






Home | Main Index | Thread Index

Privacy Policy | PostgreSQL Archives hosted by Command Prompt, Inc. | Designed by tinysofa
Copyright © 1996 – 2008 PostgreSQL Global Development Group