1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

NOT IN ('') の結果がOracleとPostgreSQLでは異なる

Last updated at Posted at 2021-04-29

例えば、EMPLOYEES表のUSERIDの値が、NULLも空文字も含まないとき。
以下のSQLは、Oracleは0件、PostgreSQLは全件となる(SQL Serverも全件)。

SELECT
  USERID
FROM
  EMPLOYEES 
WHERE
  USERID NOT IN ('');

Oracleでは自動的に空文字("")を nullに変換しますが、PostgreSQLではnullに変換しません。
OracleからPostgreSQLへの移行(#NULLと空文字の違い)

より、
USERID NOT IN ('')が
PostgreSQLの場合、USERID != ''
Oracleの場合、USERID != NULL ※USERID IS NOT NULLでないので0件
となったと思われる。

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?