Advertisement
Guest User

Untitled

a guest
May 23rd, 2019
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.16 KB | None | 0 0
  1. -- Query estatísticas
  2.  
  3. SET @nome_do_schema = 'db_name';
  4. Select
  5. (select schema_name from information_schema.schemata where schema_name=@nome_do_schema) as "Nome do Banco de dados",
  6. (SELECT Round( Sum( data_length + index_length ) / 1024 / 1024, 3 )
  7. FROM information_schema.tables
  8. WHERE table_schema=@nome_do_schema
  9. GROUP BY table_schema) as "Tamanho do Banco de dados em Mega Bytes",
  10. (select count(*) from information_schema.tables where table_schema=@nome_do_schema and table_type='base table') as "Quant. Tabelas",
  11. (select count(*) from information_schema.statistics where table_schema=@nome_do_schema) as "Quant. Índices",
  12. (select count(*) from information_schema.views where table_schema=@nome_do_schema) as "Quant. Views",
  13. (select count(*) from information_schema.routines where routine_type ='FUNCTION' and routine_schema=@nome_do_schema) as "Quant. Funções",
  14. (select COUNT(*) from information_schema.routines where routine_type ='PROCEDURE' and routine_schema=@nome_do_schema) as "Quant. Procedimentos",
  15. (select count(*) from information_schema.triggers where trigger_schema=@nome_do_schema) as "Quant. Triggers",
  16. (select default_collation_name from information_schema.schemata where schema_name=@nome_do_schema)"Default collation do Banco de dados",
  17. (select default_character_set_name from information_schema.schemata where schema_name=@nome_do_schema)"Default charset do Banco de dados",
  18. (select sum((select count(*) from information_schema.tables where table_schema=@nome_do_schema and table_type='base table')+(select count(*) from information_schema.statistics where table_schema=@nome_do_schema)+(select count(*) from information_schema.views where table_schema=@nome_do_schema)+(select count(*) from information_schema.routines where routine_type ='FUNCTION' and routine_schema=@nome_do_schema)+(select COUNT(*) from information_schema.routines where routine_type ='PROCEDURE' and routine_schema=@nome_do_schema)+(select count(*) from information_schema.triggers where trigger_schema=@nome_do_schema))) as "Total de Objetos do Banco de dados"
  19. LIMIT 0, 1000\G
  20.  
  21.  
  22. select a.TABLE_SCHEMA, a.TABLE_TYPE , a.TABLE_NAME, a.TABLE_ROWS from information_schema.tables a where a.table_schema='db_name';
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement