Empty string inserting a zero, not a null

前端 未结 4 1373
一整个雨季
一整个雨季 2021-02-14 07:42

My insert statement looks like this:

INSERT INTO foo (bar) VALUES (\'\');

The bar field was created like so:

bar I         


        
4条回答
  •  自闭症患者
    2021-02-14 08:36

    Why should it be a NULL? You're providing a value that has an integer representation: empty strings convert to INT 0.

    Only if you didn't provide any value would the default take over.

提交回复
热议问题