MySQL中不能创建自增字段的解决方法

原因分析:

  引起MysqL不能创建自动增加的字段的原因是在MysqL5.0.2版本中的The Server sql Mode 中新加了几种 sql_mode,并且在sql的my.ini文件中的sql-mode 增加了其中的二种,一个是STRICT_TRANS_TABLES,就是导致auto_increament失败的mode,这个sql_mode主要用于 当一个值不能插入到表中是,则产生一个错误而不是一个警告并终止会话。

解决办法:

  删除或注释掉sql_mode.重启MysqL.

将my.ini中的:


# Set the sql mode to strict

sql-mode="STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"

改为:

  # Set the sql mode to strict[separator]

  #sql-mode="STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION"

  sql-mode="NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"

相关文章

SELECT a.*,b.dp_name,c.pa_name,fm_name=(CASE WHEN a.fm_n...
if not exists(select name from syscolumns where name=&am...
select a.*,pano=a.pa_no,b.pa_name,f.dp_name,e.fw_state_n...
要在 SQL Server 2019 中设置定时自动重启,可以使用 Window...
您收到的错误消息表明数据库 'EastRiver' 的...
首先我需要查询出需要使用SQL Server Profiler跟踪的数据库标...