Search Postgresql Archives

Re: default value based on select

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello

On 05/04/2008, Pedro Doria Meunier <pdoria@xxxxxxxxxxxxxx> wrote:
> Hi,
>
>  Is it possible to have a table's column default value set to some form of
>  select?
>

directly no, but you can use function

postgres=# create table a(a integer);
CREATE TABLE

postgres=# create function mx() returns int as $$select max(a) from
a$$ language sql volatile;
CREATE FUNCTION
postgres=# create table b(x integer default mx());
CREATE TABLE

Regards
Pavel Stehule
>  e.g. picking another table's value for a given SELECT ... WHERE ...
>
>  Already thankful for any insight,
>
> --
>  Pedro Doria Meunier
>  Ips. da Olaria, Edf. Jardins do Garajau, 4, r/c Y
>  9125-162 Caniço
>  Madeira - Portugal
>  --------------------------------------------------
>  Skype : pdoriam
>  Mobile: +351961720188
>
>

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux