What's the point of “NOT NULL DEFAULT '' ”?

后端 未结 7 970
时光说笑
时光说笑 2021-02-01 05:10

I\'ve seen this on a lot of fields on a DB from a project I\'ve been working on, where a column will be defined not null, but will have an empty string as the default. what\'s t

7条回答
  •  暖寄归人
    2021-02-01 06:08

    There is a difference between a null value and an empty string - at least in SQL.

    SELECT LENGTH('tata');
    4
    
    SELECT LENGTH(NULL);
    NULL
    
    SELECT LENGTH('tata')-LENGTH('');
    4
    
    SELECT LENGTH('tata')-LENGTH(NULL);
    NULL
    

提交回复
热议问题