[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Perl or Python?



On 2009.03.19 at 18:38:10 +0300, Alexey Pechnikov wrote:

> 
> Беда в том, что NULL это может быть и отсутствие информации, и ее 
> некорректность, и даже невалидность самого вопроса. Например, при 
> использовании NULL в базу может быть вставлена дата 31 февраля:
> 
> create table tests(date,value);
> insert into tests (date,value) values ('2009-02-31',NULL);
> Ну и что мы получаем:
> 
> select count(value) from tests;
> 0
> select count(*) from tests;
> 1

Это где такие базы данных берут?

$psql template1
Welcome to psql 8.3.0, the PostgreSQL interactive terminal.

Type:  \copyright for distribution terms
       \h for help with SQL commands
       \? for help with psql commands
       \g or terminate with semicolon to execute query
       \q to quit

template1=# create table tests (date timestamp, value varchar);
CREATE TABLE

template1=# insert into tests values ('2009-02-31','foo');
ERROR:  значение поля типа date/time вне диапазона: "2009-02-31"
template1=# insert into tests values ('2009-02-31',NULL);
ERROR:  значение поля типа date/time вне диапазона: "2009-02-31"

И как-то глубоко ему пофиг NULL или не NULL в соседней колонке. 
Нельзя некорректную дату вставить.


Reply to: