13

I would like to apply pagination to the results of SHOW TABLES FROM DATABASE_NAME.

Tried using the LIMIT keyword but an error is thrown.

By pagination I mean that the result(tables) returned by the query is to be displayed on multiple pages.

Quasdunk
  • 14,944
  • 3
  • 36
  • 45
Ashish Saxena
  • 434
  • 2
  • 8
  • 20
  • You can do it in your code, for the first page show from the first result to the number of results you want to show. For the second one, show from result #`( number of results per page * 1 )`, until `( number of results per page * 1 ) + results per page`, and so on, just replace the `1` with the number of the current page in a zero based count (first page is 0, the second 1, etc). – Yaniro Mar 20 '12 at 07:44

3 Answers3

32

mysql> pager less;

mysql> show tables;

ivke
  • 321
  • 3
  • 3
  • That is awesome – Alexander Zhukov Feb 09 '18 at 11:17
  • exactly what I was looking for. Thanks a ton. – McDee Apr 03 '18 at 11:04
  • Note that `less` must work on your system's command line already. For people that don't have `less` installed on their system, `more` might work as well. Might even work on Windows, but `less` isn't installed by default in some linux distro, especially when troubleshooting in a docker container (or any type of container). – beauk Jan 05 '20 at 20:07
22

you can use the different query instead (an achieve the names of the tables) like:

    SELECT TABLE_NAME FROM information_schema.TABLES 
WHERE `TABLE_SCHEMA` = 'my_db_name' LIMIT 10
Haim Evgi
  • 123,187
  • 45
  • 217
  • 223
0

You can try following

1)

SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES 
WHERE TABLE_SCHEMA = 'database_name' 
AND TABLE_NAME LIKE "a%" 
LIMIT 0,20;

2)

SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES 
WHERE TABLE_SCHEMA = 'database_name'  
LIMIT 0,50;
Mukesh
  • 7,630
  • 21
  • 105
  • 159