MariaDB——数据库登录

登录MariaDB数据库,用root账户和密码;

显示所有数据库列表;其中,information_schema、performance_schema、test、mysql,这4个库表是数据库系统自带的表,一般不放个人数据。

下边的命令,希望能对数据库系统自带的表:information_schema、performance_schema、test、mysql,有进一步的了解:

显示表结构(以users表为例)

discribe tables;

查询所有数据库的大小:

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

查询指定数据库的大小(以zabbix为例):

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

查询指定数据库中所有表的大小(以zabbix为例):

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;

查询指定数据库中指定表的大小(以zabbix数据库的history表为例):

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

参考:
https://blog.csdn.net/weixin_42627459/article/details/113902680

posted @ 2021-02-23 09:13  马踏飞燕Beautiful  阅读(1609)  评论(0编辑  收藏  举报