Count total number of tables, views, stored procedures or functions in mysql database.

You can use this queries:
-- Count Number Of PROCEDURE In A Database
select 'Procedures',Count(*) `Count` from mysql.proc 
where db='Admin' and type='PROCEDURE'
  Union ALL
-- Count Number Of Functions In A Database
select 'Functions',Count(*) `Count` from mysql.proc 
where db='Admin' and type='Function'
  Union ALL
-- Count Number Of Tables In A Database
SELECT 'Tables',COUNT(*)  AS `Count` FROM 
INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE='BASE TABLE'
and table_schema='Admin'
  Union ALL
-- Count Number Of Views In A Database
SELECT 'Views',COUNT(*) AS VIEW_COUNT FROM INFORMATION_SCHEMA.VIEWS 
where table_schema='Admin' ;
Result:

Post a Comment

0 Comments