[GENERAL] Best way to allow column to initially be null?
В списке pgsql-general по дате отправления:
| От | Glen Huang |
|---|---|
| Тема | [GENERAL] Best way to allow column to initially be null? |
| Дата | |
| Msg-id | 0780AF5A-AE89-4255-9857-EC3EF91570A3@gmail.com обсуждение исходный текст |
| Ответы |
Re: [GENERAL] Best way to allow column to initially be null?
|
| Список | pgsql-general |
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 readingthe 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 raiseexception 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@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general
В списке pgsql-general по дате отправления:
Сайт использует файлы cookie для корректной работы и повышения удобства. Нажимая кнопку «Принять» или продолжая пользоваться сайтом, вы соглашаетесь на их использование в соответствии с Политикой в отношении обработки cookie ООО «ППГ», в том числе на передачу данных из файлов cookie сторонним статистическим и рекламным службам. Вы можете управлять настройками cookie через параметры вашего браузера