如何通过“SHOW TABLES”返回订购的表?
例如,information_schema
数据库的输出如下所示:
CHARACTER_SETS
COLLATIONS
COLLATION_CHARACTER_SET_APPLICABILITY
COLUMNS
COLUMN_PRIVILEGES
ENGINES
EVENTS
FILES
GLOBAL_STATUS
GLOBAL_VARIABLES
KEY_COLUMN_USAGE
PARAMETERS
PARTITIONS
PLUGINS
PROCESSLIST
PROFILING
REFERENTIAL_CONSTRAINTS
ROUTINES
SCHEMATA
SCHEMA_PRIVILEGES
SESSION_STATUS
SESSION_VARIABLES
STATISTICS
TABLES
TABLESPACES
TABLE_CONSTRAINTS
TABLE_PRIVILEGES
TRIGGERS
USER_PRIVILEGES
VIEWS
INNODB_CMP_RESET
INNODB_TRX
INNODB_CMPMEM_RESET
INNODB_LOCK_WAITS
INNODB_CMPMEM
INNODB_CMP
INNODB_LOCKS
答案 0 :(得分:8)
请参阅SHOW DATABASES does not order infomation_schema correct的Sergei Golubchik的回答:“没有SHOW命令对结果进行排序”。
如果需要排序的表名,可以查询information_schema.tables
,例如:
select table_name from information_schema.tables
where table_schema = 'your_db_name' order by table_name;
答案 1 :(得分:0)
试试这个:
SELECT * FROM information_schema.TABLES WHERE TABLE_SCHEMA = 'information_schema' ORDER BY TABLE_NAME
答案 2 :(得分:0)
下面的代码非常适合我在我的任何数据库中列出特定的表,并按照他们的名字对它们进行排序。
results