Field "details" doesn't have a default value

[转载:原文链接http://my.oschina.net/wojibuzhu/blog/511104]

MySQL 1364 错误提示:#1364 - Field "details" doesn‘t have a default value。大概意思是:details字段没有默认的数值;也就是说我们没有为其分配数值,而表中此字段也没有设置默认值。这是MySQL5出来后搞出来的东东,认真看一下my.ini文件中有这样一段: my.ini中相关代码

# Set the SQL mode to strict # sql-mode="STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"    sql-mode="STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"

假如您无法看到my.ini,你可以执行以下SQL命令。

SQL代码    SELECT @@GLOBAL.sql_mode;

您可能一下子就注意到:STRICT_TRANS_TABLES(存储引擎启用严格模式,非法数据值被拒绝)。这也就是为什么我们插入数据时返回1364的原因:details字段没有设置默认值。

解决办法有两种: 第一种:数据库设计时,为可能没有数据的字段设置默认值。 第二种:设置SQL的模式,此有两种方法: (1),配置my.ini,去掉:STRICT_TRANS_TABLES my.ini配置代码    # Set the SQL mode to strict # sql-mode="STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"    sql-mode="NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"

(2),运行SQL命令。注:此命令需要权限!

SQL代码    SET @@GLOBAL.sql_mode="NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION";

Field "details" doesn't have a default value

时间: 2024-10-13 17:15:50

Field "details" doesn't have a default value的相关文章

错误号:1364 错误信息:Field 'platId' doesn't have a default value

1. 错误描述 错误号:1364 错误信息:Field 'platId' doesn't have a default value insert into `use`.`t_platform_scale` () values () 2.错误原因 由于在建表时,给platId一个not null限制,而且没有给默认值,在插入数据时未插入,导致报错 3.解决办法 (1)修改platId可以为null (2)插入数据时一定要插入platId 版权声明:本文为博主原创文章,未经博主允许不得转载. 错误号

Mysql添加用户错误:ERROR 1364 (HY000): Field 'ssl_cipher' doesn't have a default value解决方法

添加用户 insert into mysql.user(Host,User,Password) values("localhost","test",password("1234")); 报以下的错误 ERROR 1364 (HY000): Field 'ssl_cipher' doesn't have a default value错误 mysql5.1以上版本,我是在5.6版本上操作的. 错语原因: mysql用户表的中某些字段不能为空,没有默

[mysql]ERROR 1364 (HY000): Field 'ssl_cipher' doesn't have a default value

From: http://m.blog.csdn.net/blog/langkeziju/13511411 我的MySQL版本为5.6.14版本,是二进制包安装的(虽然是二进制包安装的,但是以下问题同样适用于源码安装包安装的MySQL) 今天在我的测试库上添加一个新用户,报错: [[email protected] ~]$ mysql -uroot -p123456 Warning: Using a password on the command line interface can be in

Django model :add a non-nullable field 'SKU' to product without a default; we can't do that

You are trying to add a non-nullable field 'SKU' to product without a default; we can't do that (the database needs something to populate existing rows). Please select a fix: 1) Provide a one-off default now (will be set on all existing rows) 2) Quit

Field 'id' doesn't have a default value

Field 'id' doesn't have a default value 如果出现以上错误,可能是设计数据库时,主键id没有设置 自动递增 打开 navicat.exe  选择设计表在自动递增上打钩,在点击保存,从起eclipse ,再重新部署项目,问题解决. Field 'id' doesn't have a default value

Field 'id' doesn't have a default value问题解决方法

今天在写数据库文件时,遇到了Field 'id' doesn't have a default value异常.hbm.xml文件pk <id name="id" column="id" type="integer"> <generator class="native" /> </id> 解决办法:在数据库表设置中,将主键设为Auto Increment即可. Field 'id' does

Caused by: java.sql.SQLException: Field &#39;id&#39; doesn&#39;t have a default value

1.错误描述 org.hibernate.exception.GenericJDBCException: error executing work at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:54) at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(Sql

Error updating database. Cause: java.sql.BatchUpdateException: Field &#39;id&#39; doesn&#39;t have a default value

异常信息 ### Error updating database. Cause: java.sql.BatchUpdateException: Field 'id' doesn't have a default value Query is: INSERT INTO `test`.`order` ( `order`.`code`, `order`.`create_date`, `order`.`status`, ) VALUES ( ?, ?, 原因 数据库表设计时候id没有加自动增长 myba

mysql Field &#39;xxx&#39; doesn&#39;t have a default value

今天在对一个项目在进行数据库迁移后,进行测试时,出现了Field 'xxx' doesn't have a default value的错误,而这个错误在迁移前从未出现过.后来经过查询手册等资料,发现错误的原因是配置不同:出错的mysql服务器,在系统变量sql_mode里,多了个参数: STRICT_TRANS_TABLES,去掉后就不报错了.今天接触了很多知识点,我要一点点捋. 参考资料 sql_mode strict SQL mode 首先了解一些mysql系统变量sql_mode. 根据