How to count all tables size in MySql/MariaDB database

Sometimes we need to see the size of all tables in our MySql/MariaDB database.

The easiest way is to make such query:
SELECT
    table_schema AS `database`,
    table_name AS `table`,
    round(((data_length + index_length) / 1024 / 1024), 2) AS `table size (MB)`
FROM information_schema.tables
ORDER BY `table size (MB)` DESC;

If you want to list all tables with size greater than e.g. 300MB then make this query:
SELECT
    table_schema AS `database`,
    table_name AS `table`,
    round(((data_length + index_length) / 1024 / 1024), 2) AS `table size (MB)`
FROM information_schema.tables
HAVING `table size (MB)`> 300
ORDER BY `table size (MB)` DESC;