Search Postgresql Archives

Best way to allow column to initially be null?

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

 



Hi,

I’m trying to make a column have these properties:

1. When a row is inserted, this column is allowed to be null.
2. When the row is updated, no null can be assigned to it this column.

I initially thought I can drop the not null constraint before insertion and turn it back on after that, but after reading the doc it seems turning on not null constraint requires not columns contain null value, so looks like it won’t work.

My current approach is to not set the not null constraint in the table and use a before update trigger to manually raise exception when the column is null. But it doesn’t seem as elegant.

Is there a better way?

Regards,
Glen

-- 
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general




[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