Re: Select default values

From: "Scott Marlowe" <scott(dot)marlowe(at)gmail(dot)com>
To: "Maximilian Tyrtania" <maximilian(dot)tyrtania(at)onlinehome(dot)de>
Cc: "A(dot) Kretschmer" <andreas(dot)kretschmer(at)schollglas(dot)com>, pgsql-sql(at)postgresql(dot)org
Subject: Re: Select default values
Date: 2008-07-23 14:29:58
Message-ID: dcc563d10807230729r1aa17fbdja849a6fea465bf4a@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

On Wed, Jul 23, 2008 at 3:57 AM, Maximilian Tyrtania
<maximilian(dot)tyrtania(at)onlinehome(dot)de> wrote:
> Hi,
>
>> am Wed, dem 23.07.2008, um 10:32:58 +0200 mailte Maximilian Tyrtania
>> folgendes:
>>> Hi there, just a quickie: Is there a way to select all default values of a
>>> given table? Something like "Select Default values from sometable" ?
>>
>> test=# create table t_with_defaults( s1 int default 1, s2 int default 2);
>> CREATE TABLE
>> test=*# select ordinal_position, column_name, column_default from
>> information_schema.columns where table_name='t_with_defaults' order by 1;
>> ordinal_position | column_name | column_default
>> ------------------+-------------+----------------
>> 1 | s1 | 1
>> 2 | s2 | 2
>> (2 rows)
>
> This is probably what I should do, the only problem is that the output of
> the given query looks a lot less nice when the default looks like this
>
> nextval('mitarbeiter_serial'::regclass)
>
> I'd prefer to just receive the actual value of that function. Okay, I could
> just execute that statement, but, hmm, still, that seems akward.

Until you run that function, you don't know what the output might be
because of possible race condtitions.

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Emi Lu 2008-07-23 18:22:20 Query prepared plan
Previous Message Maximilian Tyrtania 2008-07-23 12:06:02 Re: Select default values