天天看點

檢視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;
           

繼續閱讀