I want to get the list of last n number of table names present in a schema in a particular database. The problem is there are lots of tables and is not convenient to scroll through all of them to reach the end. Is there a way I can use something equivalent of tail -f command which is used to look at the recent updates in a log file.
I have tried something like tail -f \dt in the current schema. But doesn't work.
CodePudding user response:
This is it:
select * from (
SELECT table_name,ROW_NUMBER () OVER (
ORDER BY table_name desc
) as id FROM information_schema.tables
) where id<=5;
for example you can replace 5 with any number.
CodePudding user response:
It should be with alias name in sub query
select * from (
SELECT table_name,ROW_NUMBER () OVER (
ORDER BY table_name desc
) as id FROM information_schema.tables
)x where id<=5;