postgresql空和null的区别

时间:2022-11-09 14:24:31
create table test(name varchar(32));
pg2=# insert into test values('');
INSERT 0 1
pg2=# insert into test values(' ');
INSERT 0 1
pg2=# insert into test values(null);
INSERT 0 1
pg2=# select * from test;
 name
------
 
 
 
(3 rows)

pg2=# select * from test where name is null;
 name
------
 
(1 row)

pg2=# select * from test where name='';     
 name
------
 
(1 row)

pg2=# select * from test where name=' ';
 name
------
 
(1 row)