且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在MySQL中使用SELECT语句获取表名

更新时间:2023-02-26 09:46:17

要获取所有表的名称,请使用:

To get the name of all tables use:

SELECT table_name FROM information_schema.tables;

要从特定数据库中获取表的名称,请使用:

To get the name of the tables from a specific database use:

SELECT table_name FROM information_schema.tables
WHERE table_schema = 'your_database_name';

现在,要回答原始问题,请使用以下查询:

Now, to answer the original question, use this query:

INSERT INTO table_name
    SELECT table_name FROM information_schema.tables
        WHERE table_schema = 'your_database_name';

有关更多详细信息,请参见: http://dev.mysql .com/doc/refman/5.0/en/information-schema.html

For more details see: http://dev.mysql.com/doc/refman/5.0/en/information-schema.html