查看MySQL數據庫表存儲引擎,修改數據庫表的存儲引擎

mysql數據庫報錯:

Caused by: 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.
    at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1094)
    at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4208)
    at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4140)
    at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2597)
    at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2758)
    at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2826)
    at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:2082)
    at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:2212)
    at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeQuery(NewProxyPreparedStatement.java:1418)
    at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.extract(ResultSetReturnImpl.java:82)
    ... 243 more

原因:當前數據庫表存儲引擎不支持事務,查看數據庫表存儲引擎,並且修改表的存儲引擎爲InnoDB。

 

#查看MySQL數據庫所能支持的存儲引擎

show engines;
show variables like '%storage_engine%';


#設置MySQL存儲引擎

set default_storage_engine=InnoDB


#查看錶的存儲引擎信息

show table status where name='table_name';
show table status from `db_name` where name='table_name';
select table_schema, table_name, table_type, engine from information_schema.tables where  table_name = 'table_name'; 


#查看當前數據庫所有表的存儲引擎信息

show table status from `db_name`;


#修改表的存儲引擎信息

alter table cm_sequence engine = InnoDB;


 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章