NOT NULL and postgres 6.5.2
NOT NULL and postgres 6.5.2
От:
Stephan Bauer <stephan_bauer@gmx.de>
Дата:
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
Re: [SQL] NOT NULL and postgres 6.5.2
От:
"Oliver Elphick" <olly@lfix.co.uk>
Дата:
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 ID 32B8FAA1 ======================================== "But be ye doers of the word, and not hearers only, deceiving your own selves." James 1:22
Re: [SQL] NOT NULL and postgres 6.5.2
От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
Stephan Bauer 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