Re: BUG #9088: default are not working - Mailing list pgsql-bugs

From Thomas Kellerer
Subject Re: BUG #9088: default are not working
Date
Msg-id 52F01888.4020808@gmx.net
Whole thread Raw
In response to BUG #9088: default are not working  (plademan@comcast.net)
List pgsql-bugs
plademan@comcast.net wrote on 03.02.2014 23:23:> create table default_test
> (
>    userId   varchar(20)   default 'test',
>    date1    timestamp     default now(),
>    date2    timestamp     default current_timestamp,
>    date3    timestamp     default localtimestamp
> );
>
> insert into default_test
> ( userId, date1, date2, date3 )
> values
> ( null, null, null, null );
>
> select * from default_test;

You explicitely stated that you want to put NULL into those columns, therefor the default value does not apply.

The default value is only used if the colum is not listed at all in the INSERT statement.

pgsql-bugs by date:

Previous
From: plademan@comcast.net
Date:
Subject: BUG #9088: default are not working
Next
From: Marko Tiikkaja
Date:
Subject: Re: BUG #9088: default are not working