2012-11-08 198 views
5

「SHOW TABLES」返回的表如何排序?MySQL:排序順序「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 
+1

我想和其他任何表一樣。訂單不保證,它是一套。不是遊標。 –

回答

7

SHOW DATABASES does not order infomation_schema correct見謝爾蓋Golubchik的回答是: 「沒有SHOW命令排序的結果」。

如果你需要的名字排序表,你可以查詢information_schema.tables,是這樣的:

select table_name from information_schema.tables 
where table_schema = 'your_db_name' order by table_name; 
0

試試這個:

SELECT * FROM information_schema.TABLES WHERE TABLE_SCHEMA = 'information_schema' ORDER BY TABLE_NAME 
0

下面的代碼工作得很好,對我來說,名單上的任何我的數據庫的特定表,並通過他們的姓名進行排序問。

SELECT TABLE_NAME FROM information_schema.TABLES WHERE TABLE_SCHEMA = 'your_database_here' AND TABLE_NAME LIKE '%letters_from_your_table_here%' ORDER BY TABLE_NAME DESC