执行MySql更新报错:error code [1785]

应用连接MySql数据库,报错,报错信息如下:

### Error updating database.  Cause: java.sql.SQLException: When @@GLOBAL.ENFORCE_GTID_CONSISTENCY = 1,
 updates to non-transactional tables can only be done in either autocommitted statements or single-statement transactions, 
and never in the same statement as updates to transactional tables.



### Cause: java.sql.SQLException: When @@GLOBAL.ENFORCE_GTID_CONSISTENCY = 1, updates to non-transactional tables can only be done in either autocommitted statements or single-statement transactions, and never in the same statement as updates to transactional tables.
; uncategorized SQLException for SQL []; SQL state [HY000]; error code [1785]; When @@GLOBAL.ENFORCE_GTID_CONSISTENCY = 1, updates to non-transactional tables can only be done in either autocommitted statements or single-statement transactions, and never in the same statement as updates to transactional tables.; nested exception is java.sql.SQLException: When @@GLOBAL.ENFORCE_GTID_CONSISTENCY = 1, updates to non-transactional tables can only be done in either autocommitted statements or single-statement transactions, and never in the same statement as updates to transactional tables.

 error code [1785]

通过各种查询发现是建表语句和数据库版本的的问题。

本地服务器版本:5.1.73

服务器版本:5.6


而在建表语句中,表的类型为:

ENGINE=MyISAM

改为:InnoDB类型即可。更改的地方在:


再次执行,SQL即可成功执行。

InnoDB和MyISAM是许多人在使用MySQL时最常用的两个表类型,这两个表类型各有优劣,视具体应用而定。基本的差别为:MyISAM类型不支持事务处理等高级处理,而InnoDB类型支持。MyISAM类型的表强调的是性能,其执行数度比InnoDB类型更快,但是不提供事务支持,而InnoDB提供事务支持已经外部键等高级数据库功能。



你可能感兴趣的:(执行MySql更新报错:error code [1785])