Reputation: 17333
I have some code like the following:
$import = "CREATE TABLE foo..."; // an SQL import containing some CREATE TABLE, ALTER TABLE, etc.
$result = $mysqli->query($import) or die ($mysqli->error);
How do I find the names of all the tables that were created in the last SQL query (i.e. the $import
statement)? I was wondering if there was a special way in MySQL to do this, rather than just searching the statement for CREATE TABLE
, which is kind-of a dirty hack.
Upvotes: 1
Views: 60
Reputation: 28529
use the 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
Upvotes: 3