Why does Oracle 9i treat an empty string as NULL?

后端 未结 10 1360
佛祖请我去吃肉
佛祖请我去吃肉 2020-11-21 23:39

I know that it does consider \' \' as NULL, but that doesn\'t do much to tell me why this is the case. As I understand the SQL specifications

10条回答
  •  北海茫月
    2020-11-22 00:11

    According to official 11g docs

    Oracle Database currently treats a character value with a length of zero as null. However, this may not continue to be true in future releases, and Oracle recommends that you do not treat empty strings the same as nulls.

    Possible reasons

    1. val IS NOT NULL is more readable than val != ''
    2. No need to check both conditions val != '' and val IS NOT NULL

提交回复
热议问题