获取所有表的名称使用:
SELECT table_name FROM information_schema.tables;
要从特定数据库中获取表的名称,请使用:
SELECT table_name FROM information_schema.tables where table_schema='';
现在,要回答原始问题,请使用以下查询:
INSERT INTO SELECT table_name FROM information_schema.tables WHERE table_schema = '';
有关更多详细信息,请参阅: http : //dev.mysql.com/doc/refman/5.0/en/information-schema.html
尝试:
select * from information_schema.tables
请参阅: http : //dev.mysql.com/doc/refman/5.0/en/information-schema.html
如果我们有多个数据库,并且我们需要select特定数据库的所有表,我们可以使用TABLE_SCHEMA来定义数据库名称:
select table_name from information_schema.tables where TABLE_SCHEMA='dbname';
除了使用INFORMATION_SCHEMA表,要使用SHOW TABLES插入表中,您可以使用以下内容
看一下数据库information_schema中的表TABLES 。 它包含有关其他数据库中表的信息。 但是,如果你在共享主机,你可能无法访问它。
我想你可以从INFORMATION_SCHEMA TABLES获得你想要的数据。
你可以在这里find更多的信息: http : //dev.mysql.com/doc/refman/5.0/en/tables-table.html
MySQL INFORMATION_SCHEMA.TABLES表包含有关这两个表(不是临时的,而是永久的)和视图的数据。 TABLE_TYPE列定义这是否是表或视图的logging(对于表TABLE_TYPE ='BASE TABLE'和视图TABLE_TYPE ='VIEW')。 所以如果你想从模式(数据库)表中看到只有以下查询:
SELECT * FROM information_schema.tables WHERE table_type='BASE TABLE' AND table_schema='myschema'
SELECT table_name FROM information_schema.tables WHERE table_schema = DATABASE()
还有另一种更简单的方法来获取表名
SHOW TABLES FROM
我认为这可能是有帮助的,如果你想select包含特定单词的表格,你可以很容易地使用“SELECT”(而不是“SHOW”)来做到这一点。 下面的查询很容易缩小search到包含“关键字”
SELECT * FROM information_schema.tables WHERE table_name like "%keyword%"
要插入,更新和删除,请执行以下操作:
$teste = array('LOW_PRIORITY', 'DELAYED', 'HIGH_PRIORITY', 'IGNORE', 'INTO', 'INSERT', 'UPDATE', 'DELETE', 'QUICK', 'FROM'); $teste1 = array("\t", "\n", "\r", "\0", "\x0B"); $strsql = trim(str_ireplace($teste1, ' ', str_ireplace($teste, '', $strsql))); $nomeTabela = substr($strsql, 0, strpos($strsql, ' ')); print($nomeTabela); exit;