Mysql不能默认为空值吗?

ojuju10 2009-01-07 09:33:07
例如下面代码就报错,难道字段不能默认为''?
create table t11(id int default '' )

Error Code : 1067
Invalid default value for 'id'
(0 ms taken)
...全文
129 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
wwwwb 2009-01-07
  • 打赏
  • 举报
回复
插入时MYSQL自动转换了
ojuju10 2009-01-07
  • 打赏
  • 举报
回复
1楼的,但是插入''不报错啊,不过插入'',显示的全部为0

create table t11(id int );
insert into t11 select '';
insert into t11 select '';

select * from t11;


------------------------
create table t11(id int default null )
还不如不要默认值
直接
create table t11(id int )
ojuju10 2009-01-07
  • 打赏
  • 举报
回复
ding
wwwwb 2009-01-07
  • 打赏
  • 举报
回复
create table t11(id int default null )
数字型字段默认值为空字符串?

56,679

社区成员

发帖
与我相关
我的任务
社区描述
MySQL相关内容讨论专区
社区管理员
  • MySQL
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧