Can I insert an empty string in a NOT NULL field?

后端 未结 3 2259
盖世英雄少女心
盖世英雄少女心 2021-02-19 16:03

Can I insert an empty string in a not null field?

insert into xyz(A,B) values(1,\'\');  // is this possible if B is NOT NULL?
3条回答
  •  攒了一身酷
    2021-02-19 17:04

    Yes you can... The concept of the NULL value is a common source of confusion for newcomers to SQL, who often think that NULL is the same as an empty string '', or a value of zero.

    This is not the case. Conceptually, NULL means "a missing unknown value" and it is treated somewhat differently from other values. For example, to test for NULL, you cannot use the arithmetic comparison operators such as =, <, or <> in most DBMSes.

提交回复
热议问题