How to display all the MySQL tables in one line?

MySQLMySQLi Database

Use information_schema.tables to display all the tables. With that, se the database name as well, so that you can display tables only from a specific database.

Let us now display all the tables in the database “web” −

mysql> select group_concat(table_name) from information_schema.tables where table_schema='web';

This will produce the following output −

+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| group_concat(table_name) |
+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| demo_table725,demotabe619,demotabe620,demotable211,demotable212,demotable213,demotable214,demotable215,demotable216,demotable217,demotable218,demotable219,demotable220,demotable221,demotable222,demotable223,demotable224,demotable225,demotable226,demotable227,demotable228,demotable229,demotable230,demotable231,demotable232,demotable233,demotable234,demotable235,demotable236,demotable237,demotable238,demotable239,demotable240,demotable241,demotable244,demotable245,demotable246,demotable247,demotable248,demotable249,demotable250,demotable251,demotable252,demotable
253,demotable254,demotable255,demotable256,demotable257,demotable258,demotable259,demotable260,demotable261,demotable262,demotable263,demotable264,demotable265,demotable266,demotable267,demotable268,demotable269,demotable270,demotable271,demotable272,demotable273,demotable274,demotable275,demotable276,demotable277,demotable278,demotable279,demotable280,demotable281,demotable282,demotable283,demotable284,demotable285,demotable286,demotable287,demotable28 |
+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set, 1 warning (0.01 sec)
raja
Published on 26-Sep-2019 07:13:10
Advertisements