Re: [SQL] NOT NULL and postgres 6.5.2

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: [SQL] NOT NULL and postgres 6.5.2
Дата
Msg-id 12783.940175880@sss.pgh.pa.us
обсуждение исходный текст
Ответ на NOT NULL and postgres 6.5.2  (Stephan Bauer <stephan_bauer@gmx.de>)
Список pgsql-sql
Stephan Bauer <stephan_bauer@gmx.de> writes:
> CREATE TABLE anzeigen (
> ...
>         name                    varchar(30) NOT NULL,
> ...
> );

> The following statement _will_ be inserted:

> INSERT INTO anzeigen ( ... name ...) 
> VALUES ( ..., '', ...);

> What is my problem?

An empty string '' is quite different from a NULL.

If you want to forbid empty strings you could add a constraint
expression, eg, CHECK (name <> '').
        regards, tom lane


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

Предыдущее
От: "Oliver Elphick"
Дата:
Сообщение: Re: [SQL] NOT NULL and postgres 6.5.2
Следующее
От: Daniel Péder
Дата:
Сообщение: insertable views - not copy-able ?