Oracle not distinguishing between nulls and empty strings?

前端 未结 5 1480
时光说笑
时光说笑 2020-12-06 17:01

Apparently oracle doesn\'t seem to distinguish between empty strings and nulls. E.g.

Select name from TABLE_A where id=100;
  ID   NAME
  100  null

Update          


        
5条回答
  •  再見小時候
    2020-12-06 17:28

    Which is why smart people like Date say that you should NEVER use nulls.

    (No, I have to be precise. It's in fact only just a single one of the almost hundreds of reasons he has mentioned over this past few decades to support that claim.)

    EDIT

    I actually also wanted to respond to this :

    "Making VARCHAR to do such a distinction will break tons of code."

    Yeah, and surely, breaking at least the spirit of the standard by replacing the "empty string" by null on every update is a lesser evil ?

    (Note : null is not equal to anything, not even itself, so after assigning the empty string to a column, oracle will give you a value in that column that is NOT the same as the value that you said you wanted to appear there. Wow.)

提交回复
热议问题