[pgsql-jp: 41857] Re: POSTGRESQL9.3について
Tomoaki Sato
sato @ sraoss.co.jp
2016年 1月 14日 (木) 21:23:12 JST
佐藤です。
> 水口と申します
>
> VCHARの空文字、NULL判定についてですが
>
> Postgresql9.1を利用は
> NULLと空文字は区別されていましたが
> Where is null
> と
> Where = ''
> は異なる結果を取得する
>
> Postgresql9.3では同一とみなされるようなのですが
> どのバージョンからこの様になっているのか
> どなたか教えてください。
いや、9.3 でも null と空文字は区別されてますよ。
postgres=# select version();
version
---------------------------------------------------------------------------------------------------------------
PostgreSQL 9.3.10 on x86_64-unknown-linux-gnu, compiled by gcc (GCC) 4.8.3 20140911 (Red Hat 4.8.3-9), 64-bit
(1 row)
postgres=# create table t (c1 int, c2 varchar(255));
CREATE TABLE
postgres=# insert into t values (1, null), (2, '');
INSERT 0 2
postgres=# select * from t where c2 is null;
c1 | c2
----+----
1 |
(1 row)
postgres=# select * from t where c2 = '';
c1 | c2
----+----
2 |
(1 row)
----
Tomoaki Sato <sato @ sraoss.co.jp>
SRA OSS, Inc. Japan
pgsql-jp メーリングリストの案内