Mysql--常用命令

1.通过 show processlist; 或 show full processlist; 命令查看当前执行的查询

Mysql--常用命令_第1张图片

2. 如果进行一直占用,通过 kill 10,将命令终止

3.#查看库占用空间

SELECT
table_schema AS '数据库',
SUM(table_rows) AS '记录数',
SUM(TRUNCATE(data_length/1024/1024, 2)) AS '数据容量(MB)',
SUM(TRUNCATE(index_length/1024/1024, 2)) AS '索引容量(MB)'
FROM information_schema.tables
GROUP BY table_schema
ORDER BY SUM(data_length) DESC, SUM(index_length) DESC;

Mysql--常用命令_第2张图片

 4.#查看库各表占用空间

SELECT
table_schema AS '数据库',
table_name AS '表名',
table_rows AS '记录数',
TRUNCATE(data_length/1024/1024, 2) AS '数据容量(MB)',
TRUNCATE(index_length/1024/1024, 2) AS '索引容量(MB)'
FROM information_schema.tables
WHERE table_schema='xxl-job-test'
ORDER BY data_length DESC, index_length DESC;

Mysql--常用命令_第3张图片

5.#查看表占用空间

SELECT CONCAT(ROUND(SUM(data_length/1024/1024),2),'MB') AS DATA FROM TABLES WHERE table_schema='xxl-job-test' AND table_name='XXL_JOB_QRTZ_TRIGGER_LOG';

 参考文献:https://www.jb51.net/article/251126.htm

6.查询时间

SELECT CURRENT_DATE();        //格式:2022-09-30

SELECT UNIX_TIMESTAMP(NOW());//格式:1664509029

你可能感兴趣的:(mysql,数据库)