關於Mysql(MariaDB)的基本操做命令指南

MYSQL基本命令操做

1.登陸方法:mysql

mysql -u root -p

2.顯示全部數據庫:sql

show databases;

3.操做指定數據庫(以information_schema爲例)數據庫

use information_schema

4.顯示全部的表ide

show tables;

5.顯示錶結構(以users表爲例)orm

discribe tables;

6.查詢全部數據庫的大小:it

select concat(round(sum(data_length/1024/1024),2),'MB') as data from tables;

7.查詢指定數據庫的大小(以zabbix爲例):io

select concat(round(sum(data_length/1024/1024),2),'MB') as data from tables where table_schema='zabbix';

8.查詢指定數據庫中全部表的大小(以zabbix爲例):table

SELECT TABLE_NAME,DATA_LENGTH+INDEX_LENGTH,TABLE_ROWS,concat(round((DATA_LENGTH+INDEX_LENGTH)/1024/1024,2), 'MB') as data

FROM information_schema.tables WHERE TABLE_SCHEMA='zabbix' ORDER BY DATA_LENGTH+INDEX_LENGTH desc;form

9.查詢指定數據庫中指定表的大小(以zabbix數據庫的history表爲例):class

select concat(round(sum(data_length/1024/1024),2),'MB') as data from tables where table_schema='zabbix' and table_name='history';``

相關文章
相關標籤/搜索