如何使用PHP查找在最后一个SQL语句中创建的所有表的名称?
How to find the names of all tables created in the last SQL statement using PHP?
我有一些代码如下:
$import = "CREATE TABLE foo..."; // an SQL import containing some CREATE TABLE, ALTER TABLE, etc.
$result = $mysqli->query($import) or die ($mysqli->error);
如何找到在最后一个 SQL 查询(即 $import
语句)中创建的所有表的名称?我想知道 MySQL 中是否有一种特殊的方法来执行此操作,而不是仅仅搜索 CREATE TABLE
的语句,这是一种肮脏的技巧。
使用information_schema.TABLES
$time = time();
//create tables here
...
select table_name, create_time
from information_schema.TABLES
where create_time > $time
where table_schema = 'andomar'
order by CREATE_TIME desc
我有一些代码如下:
$import = "CREATE TABLE foo..."; // an SQL import containing some CREATE TABLE, ALTER TABLE, etc.
$result = $mysqli->query($import) or die ($mysqli->error);
如何找到在最后一个 SQL 查询(即 $import
语句)中创建的所有表的名称?我想知道 MySQL 中是否有一种特殊的方法来执行此操作,而不是仅仅搜索 CREATE TABLE
的语句,这是一种肮脏的技巧。
使用information_schema.TABLES
$time = time();
//create tables here
...
select table_name, create_time
from information_schema.TABLES
where create_time > $time
where table_schema = 'andomar'
order by CREATE_TIME desc