mysql如何为空字符串

在mysql中,我们可以使用空字符串来表示某些字段的值为空。下面给大家介绍如何在mysql中使用空字符串。

-- 创建一个名为test的表 create table test( id int(11) not null primary key auto_increment, name varchar(50) not null default '' ); -- 插入一条数据,name字段为空字符串 insert into test(name) values(''); -- 查询test表的数据 select * from test; 结果如下: +----+------+ | id | name | +----+------+ | 1 | | +----+------+