2
有沒有辦法使用JDBC獲取MySql表的存儲引擎。 我已經使用元數據來獲取列名稱,類型,主鍵,索引等其他表信息...但沒有找到如何獲得引擎如何使用jdbc獲取存儲引擎
有沒有辦法使用JDBC獲取MySql表的存儲引擎。 我已經使用元數據來獲取列名稱,類型,主鍵,索引等其他表信息...但沒有找到如何獲得引擎如何使用jdbc獲取存儲引擎
Statement stmt = connection.createStatement();
stmt = connection.createStatement();
ResultSet rs = stmt.executeQuery("select engine from information_schema.tables where table_name='" + tableName + "';");
rs.next();
System.out.println(rs.getString(1));
您可以使用information_schema
來獲取引擎類型,例如:
SELECT ENGINE
FROM information_schema.tables
WHERE TABLE_SCHEMA=DATABASE() AND TABLE_NAME='foobar';
感謝使用它,並且它適合於我的代碼>未使用的TABLE_SCHEMA = DATABASE(),因爲我通過連接連接到我的數據庫。 –
我用過這個: Statement stmt = connection.createStatement(); stmt = connection.createStatement(); ResultSet rs = stmt.executeQuery(「從information_schema.tables中選擇引擎,其中table_name ='」+ tableName +「';」); rs.next(); System.out.println(rs.getString(1)); –