Re: Select default values

From: Maximilian Tyrtania <maximilian(dot)tyrtania(at)onlinehome(dot)de>
To: "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 09:57:08
Message-ID: C4ACCD14.302C3%maximilian.tyrtania@onlinehome.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

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.

Thanks and best wishes from Berlin

Maximilian Tyrtania

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Pavel Stehule 2008-07-23 10:19:48 Re: Select default values
Previous Message Maximilian Tyrtania 2008-07-23 09:49:25 Re: Select default values