显示表MySQL结果的别名

时间:2012-07-07 20:26:43

标签: mysql sql list

在MySQL中执行SHOW TABLES FROM your_db_name_here 时,结果将 Tables_in_ {your_db_name_here} 作为索引。我想改变它,就像这样:

SHOW TABLES as _tables FROM mydb;

或类似

SELECT Tables_in_mydb AS _tables FROM (SHOW TABLES FROM mydb);

有什么想法吗?

1 个答案:

答案 0 :(得分:9)

INFORMATION_SCHEMA数据库进行交互通常更容易:

http://dev.mysql.com/doc/refman/5.0/en/tables-table.html

示例:

SELECT TABLE_NAME AS _tables 
FROM INFORMATION_SCHEMA.TABLES 
WHERE TABLE_SCHEMA = 'mydb'