1. 程式人生 > >檢視MySQL資料庫表儲存引擎,修改資料庫表的儲存引擎

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