| От | Richard Huxton |
|---|---|
| Тема | Re: Inserts with incomplete rows... NOT NULL constraints |
| Дата | |
| Msg-id | 411A2057.60109@archonet.com обсуждение исходный текст |
| Ответ на | Inserts with incomplete rows... NOT NULL constraints (Lars Erik Thorsplass <thorsplass@gmail.com>) |
| Список | pgsql-sql |
Lars Erik Thorsplass wrote: > The problem am now facing is that postgres will try to insert a NULL > value for fields not specified in the insert query and that are > defined as NOT NULL in the table structure. Is this the correct > behaviour? Actually, what it's doing is inserting the DEFAULT value for the field in question. If you don't specify a DEFAULT, it assumes null. # CREATE TABLE test_tbl (a integer, b text DEFAULT 'bbb', c text); # INSERT INTO test_tbl (a) VALUES (1); # SELECT * FROM test_tbl; a | b | c ---+-----+--- 1 | bbb | If you specify NOT NULL and don't want to provide a value you'll need to set a DEFAULT. -- Richard Huxton Archonet Ltd
В списке pgsql-sql по дате отправления:
Сайт использует файлы cookie для корректной работы и повышения удобства. Нажимая кнопку «Принять» или продолжая пользоваться сайтом, вы соглашаетесь на их использование в соответствии с Политикой в отношении обработки cookie ООО «ППГ», в том числе на передачу данных из файлов cookie сторонним статистическим и рекламным службам. Вы можете управлять настройками cookie через параметры вашего браузера