MySQL显示表按表名排序?
您可以使用ORDERBY子句对INFORMATION_SCHEMA.TABLES中的table_name属性进行排序。分别借助ASC或DESC以升序或降序排序。语法如下-
SELECT table_name FROM information_schema.tables WHERE table_type = 'BASE TABLE' AND table_schema='yourDatabaseName' ORDER BY table_name DESC;
将数据库与名称示例一起使用,并具有一些表。首先,我们将显示所有表,之后我们将对表名进行排序。显示所有表的查询如下-
mysql> show tables;
以下是输出-
+--------------------------+ | Tables_in_sample | +--------------------------+ | blobsizedemo | | insert_prevent | | insertrecord_selecttable | | insertrecordprevent | | mytable | | newlinedemo | | notequaloperator | | sumofeverydistinct | | yourtable | +--------------------------+ 9 rows in set (0.00 sec)
这是按表名排序的查询。现在,让我们使用ORDERBY子句以降序显示所有表-
mysql> SELECT table_name -> FROM information_schema.tables -> WHERE table_type = 'BASE TABLE' AND table_schema='sample' -> ORDER BY table_name DESC;
以下是输出-
+--------------------------+ | TABLE_NAME | +--------------------------+ | yourtable | | sumofeverydistinct | | notequaloperator | | newlinedemo | | mytable | | insertrecordprevent | | insertrecord_selecttable | | insert_prevent | | blobsizedemo | +--------------------------+ 9 rows in set (0.00 sec)
热门推荐
10 八一幼儿祝福语大全简短
11 公司乔迁食堂祝福语简短
12 婚礼结束聚餐祝福语简短
13 儿媳买车妈妈祝福语简短
14 毕业送礼老师祝福语简短
15 同事辞职正常祝福语简短
16 恭贺新婚文案祝福语简短
17 金店立秋祝福语简短英文
18 婆婆高寿祝福语大全简短