mysql 数据库功能检查以及一些SQLITeye - 牛牛娱乐

mysql 数据库功能检查以及一些SQLITeye

2019-01-10 20:23:20 | 作者: 元绿 | 标签: 查询,一个,句子 | 浏览: 1310

  table_schema AS Db Name,  

  ROUND( SUM( data_length + index_length ) / 1024 / 1024, 3 ) AS Db Size (MB),  

  ROUND( SUM( data_free ) / 1024 / 1024, 3 ) AS Free Space (MB)  

FROM information_schema.tables  

GROUP BY table_schema ;  

 

 

 

 

SHOW DATABASES;    

USE information_schema;   

 

SHOW TABLES;  

 

 # 表超越1000行的

 SELECT CONCAT(table_schema,.,table_name) AS table_name,table_rows   

 FROM information_schema.tables 

 WHERE table_rows 1000  

 ORDER BY table_rows DESC;   

 

# 最大的10个表

 SELECT CONCAT(table_schema,.,table_name) table_name,   

 CONCAT(ROUND(data_length/(1024*1024),2),M) data_length   

 FROM information_schema.TABLES   

 ORDER BY data_length DESC LIMIT 10; 

 

 

# 查询一个sql句子的时刻耗费在哪里

SET @query_id=1 ; 

SELECT state,SUM(duration)  AS total_R,

ROUND(

   100*SUM(duration)/

   (SELECT  SUM(DURATION)

   FROM information_schema.PROFILING

    WHERE query_id=@query_id

 ),2) AS calls , 

 SUM(duration )/COUNT(*) AS "R/Call"

 FROM information_schema.PROFILING

WHERE query_id=@query_id

GROUP BY state 

ORDER BY total_R DESC ; 

 

 

 

 

# 查询一个sql句子的时刻耗费在哪里

SET @query_id=31969 ; 

SELECT state,SUM(duration)  AS total_R,

ROUND(

   100*SUM(duration)/

   (SELECT  SUM(DURATION)

   FROM information_schema.PROFILING

 ),2) AS calls , 

 SUM(duration )/COUNT(*) AS "R/Call"

 FROM information_schema.PROFILING

 

GROUP BY state 

ORDER BY total_R DESC ; 

 

 

 

 

 

  

 

 

版权声明
本文来源于网络,版权归原作者所有,其内容与观点不代表牛牛娱乐立场。转载文章仅为传播更有价值的信息,如采编人员采编有误或者版权原因,请与我们联系,我们核实后立即修改或删除。

猜您喜欢的文章