6

“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
4

3 回答 3

9

请参阅SHOW DATABASES 中的 Sergei Golubchik 的回答没有正确排序 infomation_schema :“没有 SHOW 命令对结果进行排序”。

如果您需要对表名进行排序,您可以查询information_schema.tables,例如:

select table_name from information_schema.tables 
 where table_schema = 'your_db_name' order by table_name;
于 2012-11-08T14:09:52.680 回答
0

试试这个:

SELECT * FROM information_schema.TABLES WHERE TABLE_SCHEMA = 'information_schema' ORDER BY TABLE_NAME 
于 2012-11-08T14:07:38.917 回答
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
于 2016-08-25T12:10:12.310 回答