Особенности работы с NULL-значениями в PostgreSQL:
CREATE TABLE foo (
id SERIAL PRIMARY KEY,
txt TEXT default 'foo',
int INTEGER DEFAULT 0,
dt TIMESTAMP DEFAULT 'now()'
);
INSERT INTO foo (txt,int,dt) VALUES ('bar',100,'1981-04-02');
INSERT INTO foo (txt,dt) VALUES ('bar1','2000-01-01');
INSERT INTO foo (txt,int) VALUES ('bar2',200);
INSERT INTO foo (txt,int,dt) VALUES (NULL,100,'1981-04-02');
INSERT INTO foo (txt,int,dt) VALUES ('bar',NULL,'1981-04-02');
INSERT INTO foo (txt,int,dt) VALUES ('bar',100,NULL);
select * from foo;
id | txt | int | dt
----+------+-----+----------------------------
1 | bar | 100 | 1981-04-02 00:00:00
2 | bar1 | 0 | 2000-01-01 00:00:00
3 | bar2 | 200 | 2003-07-10 01:35:09.251399
4 | | 100 | 1981-04-02 00:00:00
5 | bar | | 1981-04-02 00:00:00
6 | bar | 100 |
(записей: 6)
select * from foo where int = 100;
id | txt | int | dt
----+-----+-----+---------------------
1 | bar | 100 | 1981-04-02 00:00:00
4 | | 100 | 1981-04-02 00:00:00
6 | bar | 100 |
(записей: 3)
naf=# select * from foo where int = NULL;
id | txt | int | dt
----+-----+-----+----
(записей: 0)
## - Так как NULL - неопределенное значение
select * from foo where int is NULL;
id | txt | int | dt
----+-----+-----+---------------------
5 | bar | | 1981-04-02 00:00:00
(1 запись)
update foo set int=NULL where int=100;
UPDATE 3
update foo set int=100 where int is NULL;
UPDATE 4
DROP TABLE foo;
DROP INDEX foo_pkey;
DROP SEQUENCE foo_id_seq;
В Perl значение NULL передается / получается от DBI как undef.
Дата создания: 2006-05-24 12:49:01 (Фетисов Н. А. (naf))
Последнее изменение: 2006-05-24 12:49:01 (Фетисов Н. А. (naf))
Владелец: Фетисов Н. А. (naf)
Версия: 1
Wiki::Admin Карта раздела Оглавление Изменения за сутки Изменения за неделю Изменения за месяц