Should we consider empty fields as NULL values when dealing with string columns ?

Поиск
Список
Период
Сортировка
От Nagib Abi Fadel
Тема Should we consider empty fields as NULL values when dealing with string columns ?
Дата
Msg-id 001401c3bff4$49abd7f0$f664a8c0@nagib
обсуждение исходный текст
Ответы Re: [GENERAL] Should we consider empty fields as NULL values when  (Doug McNaught <doug@mcnaught.org>)
Re: [GENERAL] Should we consider empty fields as NULL values when  (Chris Travers <chris@travelamericas.com>)
Re: [GENERAL] Should we consider empty fields as NULL values when dealing with string columns ?  (Richard Huxton <dev@archonet.com>)
Список pgsql-hackers
HI,
let's say we have the following table :
 
# CREATE TABLE tempo (col1 varchar(3) not null);
CREATE TABLE
# insert INTO tempo VALUES ('');
INSERT 11420541 1
 
the insert command works.
 
The issue is that since the column col1 is defined as character with not null attribute,
shouldn't we deny such inserts (i mean inserting empty fields)???
(PS: i am using postresql 7.3.2)
 
When using script languages (like PHP) if by mistake the variable is not defined such insert is possible (let's say we have a variable $col1_value and after a long day of work we make a mistake and write it $col_value).
 
This "problem" is solved by adding the constraint:
 ALTER TABLE tempo add constraint col1_check check(col1!='');
 

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

Предыдущее
От: Doug McNaught
Дата:
Сообщение: Re: PostgreSQL port to pure Java?
Следующее
От: "Dave Page"
Дата:
Сообщение: Re: Should we consider empty fields as NULL values when dealing with string columns ?