When first starting a project, you probably just creating a few tables inside a database, but as the project gets more mature, the application is growing and you end up having so many tables. On mysql you can count the number of tables inside a database with a special query.
Before i show you the query, first let's just show list of tables inside a database, to do this we can use mysql built in command 'show tables', simply run this command:
SHOW TABLES;
Now to count how many tables inside a database, you can use this special query:
SELECT COUNT(*) FROM information_schema.TABLES WHERE TABLE_SCHEMA = 'NAME_OF_THE_DATABASE';
SELECT COUNT(*) FROM information_schema.TABLES WHERE TABLE_SCHEMA = 'office-db';
No comments:
Post a Comment