How to find MySQL temporary table storage engine

ぐ巨炮叔叔 提交于 2019-12-01 12:59:48

问题


Hi I am working with Temporary table and I would like to know the temporary table storage Engine (InnoDB, MyISAM .... )

I am using the following code to find out but it is not showing me the storage Engine.

$engine="SELECT ENGINE FROM information_schema.TABLES WHERE TABLE_SCHEMA='test' AND `TABLE_NAME`='temporary_table'";
$export = mysql_query($engine, $connection) or die ("Sql error : ".mysql_error());
while ($row = mysql_fetch_array($export, MYSQL_BOTH)) {
    printf ("ENGINE: %s ---", $row[0]);
}

But the same code is working when I try to find the storage engine for Physical tables in my DB?

Any Help is much appreciated.!! Thank you.


回答1:


Unfortunately:

Currently, the [INFORMATION_SCHEMA.]TABLES table does not list TEMPORARY tables.

I would advise parsing the result of SHOW CREATE TABLE temporary_table;

To extract only the ENGINE of this return value:

$rset = mysql_query('SHOW CREATE TABLE temporary_table;')
$row = mysql_fetch_array($rset, MYSQL_BOTH);
preg_match('/ENGINE\=(?P<engine>\w+)/', $row[1], $matches);
echo $matches['engine'];



回答2:


You will want to search the temporary tables store information_schema.temporary_tables or the global temporary table store information_schema.global_temporary_tables.

Try

`SELECT ENGINE FROM information_schema.temporary_tables WHERE TABLE_SCHEMA='test' AND `TABLE_NAME`='temporary_table'`


来源:https://stackoverflow.com/questions/16296059/how-to-find-mysql-temporary-table-storage-engine

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!