Обсуждение: NOT NULL and postgres 6.5.2
Hello all,
I have an table like this:
CREATE TABLE anzeigen (
...
name varchar(30) NOT NULL,
...
);
The following statement _will_ be inserted:
INSERT INTO anzeigen ( ... name ...)
VALUES ( ..., '', ...);
What is my problem?
Thanks in advance
Stephan Bauer
Stephan Bauer wrote: >Hello all, > >I have an table like this: > >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 not the same as null. It is a real value whereas null
is an unknown/undefined/irrelevant value.
-- Vote against SPAM: http://www.politik-digital.de/spam/ ========================================
Oliver Elphick Oliver.Elphick@lfix.co.uk
Isle of Wight http://www.lfix.co.uk/oliver PGP key from public servers; key
ID32B8FAA1 ======================================== "But be ye doers of the word, and not hearers
only, deceiving your own selves." James 1:22
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