Help Center/ GaussDB/ Developer Guide(Centralized_V2.0-8.x)/ FAQ/ What Is the Relationship Between an Empty String and NULL?
Updated on 2025-05-29 GMT+08:00

What Is the Relationship Between an Empty String and NULL?

Answer: Whether an empty string in GaussDB is NULL depends on the compatibility mode of the database.

  • A null string is judged as NULL in A-compatible mode.
    gaussdb=# CREATE DATABASE db_test1 DBCOMPATIBILITY = 'A';
    gaussdb=# \c db_test1
    db_test1=# SELECT '' IS NULL;
     ?column? 
    ----------
     t
    (1 row)
  • A null string is not judged as NULL in B-compatible mode.
    gaussdb=# CREATE DATABASE db_test2 DBCOMPATIBILITY = 'B';
    gaussdb=# \c db_test2
    db_test2=# SELECT '' IS NULL;
     ?column? 
    ----------
     f
    (1 row)