Get the App
SLTechnology News&Howtos  ›  Database  › 

Basic operating Command Guide for Mysql (MariaDB)

Shulou Source: shulou.com Published: 2022-06-01 15:17:25 09月15日 Update

MYSQL basic command operation

1. Login method:

Mysql-u root-p

two。 Show all databases:

Show databases

3. Manipulate the specified database (take information_schema as an example)

Use information_schema

4. Show all tables

Show tables

5. Show table structure (take users table as an example)

Discribe tables

6. Query the size of all databases:

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

7. Query the size of the specified database (take zabbix as an example):

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

8. Query the size of all tables in the specified database (take zabbix as an example):

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

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

9. Query the size of the specified table in the specified database (take the history table of the zabbix database as an example):

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

Tags: Data database size query command middle finger method structure login basic operation guide Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Microsoft Shulou Technology NVidia Linux Docker