Re: [GENERAL] Default column value

Поиск
Список
Период
Сортировка
От Joshua D. Drake
Тема Re: [GENERAL] Default column value
Дата
Msg-id 6f09765e-d791-af49-c3f5-fd1bfba172da@commandprompt.com
обсуждение исходный текст
Ответ на Re: [GENERAL] Default column value  (Adrian Klaver <adrian.klaver@aklaver.com>)
Список pgsql-general
On 12/30/2016 06:46 AM, Adrian Klaver wrote:
> On 12/30/2016 06:38 AM, Rich Shepard wrote:

> test=> \d default_test
>       Table "public.default_test"
>  Column |       Type        | Modifiers
> --------+-------------------+-----------
>  id     | integer           |
>  fld_1  | character varying |
>
>>

To further illustrate this, NULL means UNKNOWN, not DEFAULT. Using
Adrian's example:

postgres=# create table default_test(id int, fld_1 varchar DEFAULT NULL);
CREATE TABLE
postgres=# INSERT into default_test VALUES(1,NULL);
INSERT 0 1
postgres=# INSERT into default_test VALUES(1,DEFAULT);
INSERT 0 1
postgres=# select * from default_test ;
  id | fld_1
----+-------
   1 |
   1 |
(2 rows)

postgres=# alter table default_test alter column fld_1 set default now();
ALTER TABLE
postgres=# INSERT into default_test VALUES(1,DEFAULT);
INSERT 0 1
postgres=# INSERT into default_test VALUES(1,NULL);
INSERT 0 1
postgres=# select * from default_test ;
  id |             fld_1
----+-------------------------------
   1 |
   1 |
   1 | 2016-12-30 09:11:11.170948-08
   1 |
(4 rows)

Sincerely,

JD

--
Command Prompt, Inc.                  http://the.postgres.company/
                         +1-503-667-4564
PostgreSQL Centered full stack support, consulting and development.
Everyone appreciates your honesty, until you are honest with them.


В списке pgsql-general по дате отправления:

Предыдущее
От: Karsten Hilbert
Дата:
Сообщение: Re: [GENERAL] LYDB: Feasible to use PG roles instead ofapplication-level security?
Следующее
От: Adrian Klaver
Дата:
Сообщение: Re: [GENERAL] Default column value [ANSWERED]