default ‘’数据库里面还是个NULL。

解决方案 »

  1.   

    在mysql中,字符串类型的''与NULL是等价的吧。
    mysql> create table ttt(id int primary key, col2 text default '');
    Query OK, 0 rows affected (0.09 sec)mysql> insert into ttt values(1, null);
    Query OK, 1 row affected (0.03 sec)mysql> select * from ttt;
    +----+------+
    | id | col2 |
    +----+------+
    |  1 | NULL |
    +----+------+
    1 row in set (0.00 sec)如果default 不为''
    mysql> create table ttt(id int primary key, col2 text not null default 'abc');
    ERROR 1101 (42000): BLOB/TEXT column 'col2' can't have a default valueBLOB/TEXT类型是不能有非空的default value的。
    我用的mysql的版本是5.0.9
      

  2.   

    谢谢,我也是这么想的。
    那个破hibernate非要非空字段。气人啊。