`

Field 'id' doesn't have a default value

阅读更多
引用
Field 'id' doesn't have a default value问题所在:原来是数据设计的时候,把主键的类型定义为int的,原本想是用自增的方式来的,写sql语句的时候没有加上auto_increment,所以在数据存储的时候老是报Field 'id' doesn't have a default value,id根本就没有值啊!!
在这里总结一下:
1、打开my.ini,查找
sql-mode="STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"

修改为
sql-mode="NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"

然后重启MYSQL

2、MySQL 5 uses a strict mode which needs to be disabled.
In Windows, Goto Start-->Programs-->MySQL->MySQL Instance Config Wizard. Follow through the Reconfigure Instance option-->Detailed Configuration-->Continue Next a few screens. At the bottom under Enable TCP/IP option there is 'Enable Strict Mode'. Deslect this option (no tick). Save changes and MySQL will restart.

3、看看你的数据库定义的时候是不是把主键生成方式设置为int的,但是没有设置为自增的!!或者数据定义的时候设置一个默认值就可以了。

参考文章引自:http://hi.baidu.com/cendi/blog/item/69ff8609b18455296a60fbb2.html
1、和2方法都是通过设置sql-mod,2的那个方法其实是通过mysql的实例向导进行设置,也等于自己手动设置的时候把mode属性设置了,然后重启服务。
3的最简单给一个默认值呗。
刚刚是在做级联的时候没有设置默认值。而且是另一端设置值的,所以用第三种方法设置个默认值给他呗
分享到:
评论

相关推荐

    解决 Field 'ssl_cipher' doesn't have a default value的错误

    ### 解决Field 'ssl_cipher' doesn't have a default value的错误 #### 背景介绍 在使用MySQL数据库的过程中,可能会遇到一个特定的错误:“Field 'ssl_cipher' doesn't have a default value”。这个错误通常发生...

    MySQL之Field‘***’doesn’t have a default value错误解决办法

    在使用MySQL时,可能会遇到“Field '***' doesn't have a default value”的错误,这个问题通常发生在尝试插入数据到数据库表时,某个字段没有提供值,而该字段在表定义中被设定为非空(NOT NULL)且没有设置默认值...

    S7A驱动720版本

    - The field "Default Gateway" has been added to the NetLink's configuration property page - The string write from the OPC Server sometimes failed . This bug has been fixed - After driver uninstall...

    使用mybatis-plus的insert方法遇到的问题及解决方法(添加时id值不存在异常)

    如果你的数据库表中 `id` 字段的数据类型是字符串或其他非数字类型,那么就会出现“Field 'id' doesn't have a default value”的异常,因为数据库无法接受这种类型转换。 为了解决这个问题,我们需要告诉 MyBatis-...

    Sakemail

    .- Reduced the line sleep to 30 (tell me if this value doesn‘t work for you).27/4/981.7.0- Fixed a memory leak, thanks to Don Higgins.- Moved the string esErrorInFormatOfMsg to a property of SakPOP.-...

    php.ini-development

    directive because it is not set or is mistyped, a default value will be used. ; The value can be a string, a number, a PHP constant (e.g. E_ALL or M_PI), one ; of the INI constants (On, Off, True, ...

    Delphi7.1 Update

    * TClientDataSet doesn‘t save data to file when FileName is set and there is no existing file on disk (Quality Central 2307). * Using the Delphi 7 version of midas.dll to open an XML file that was ...

    数位板压力测试

    The device must have a point-ing ap¬para¬tus or method (such as a stylus, or a finger touching a touch pad), called the cursor, that de¬fines the current position. The cursor must be able to ...

    微软内部资料-SQL性能优化5

    This uniqueifier is a 4-byte value added as an additional sort key to only the rows that have duplicates of their primary sort key. You can see this extra value if you use DBCC PAGE to look at the ...

    计算机网络第六版答案

    Third, if ISPs decide to charge more money to highly profitable content providers (in countries where net neutrality doesn't apply), the content providers can avoid these extra payments. 16. The ...

    EhLib 9.1.024

    Have a special column to show Field Captions Can customize inplace editor and data of the cell like in DBGridEh. TDBLookupComboboxEh component Provides all functionality of TDBLookupCombobox and ...

    Google C++ Style Guide(Google C++编程规范)高清PDF

    link ▶Don't use an #include when a forward declaration would suffice. When you include a header file you introduce a dependency that will cause your code to be recompiled whenever the header file ...

    acpi控制笔记本风扇转速

    is a region field. A buffer object is also allowed as the source operand. BZ 480 Fixed a problem where the Load ASL operator allowed the source operand to be an operation region of any type. It is ...

    apache-maven-3.0.2-bin

    * [MNG-4941] - PluginDescriptorBuilder doesn't populate expression/default-value fields for mojo parameters * [MNG-4952] - [regression] RELEASE field of repository metadata is not updated upon ...

    Java邮件开发Fundamentals of the JavaMail API

    capability isn't supported by a chosen protocol, the JavaMail API doesn't magically add the capability on top of it. (As you'll soon see, this can be a problem when working with POP.) SMTP The ...

    ehlib_vcl_src_9_3.26

    Have a special column to show Field Captions Can customize inplace editor and data of the cell like in DBGridEh. TDBLookupComboboxEh component Provides all functionality of TDBLookupCombobox and ...

    EhLib 8.0 Build 8.0.023 Pro Edition FullSource for D7-XE8

    Have a special column to show Field Captions Can customize inplace editor and data of the cell like in DBGridEh. TDBLookupComboboxEh component Provides all functionality of TDBLookupCombobox and ...

    EhLib5.0.13 最新的ehlib源码

    with a scrollable list and can display and edit a field in a dataset or can works as non data-aware combo edit control. TDBNumberEditEh component represents a single-line number edit control that ...

    EhLib 6.3 Build 6.3.176 Russian version. Full source included.

    Have a special column to show Field Captions Can customize inplace editor and data of the cell like in DBGridEh. TDBLookupComboboxEh component Provides all functionality of TDBLookupCombobox and ...

Global site tag (gtag.js) - Google Analytics