Vous êtes sur la page 1sur 2

useful mysql commands:-

To find out the size of a single MySQL database called rcubemail (which displays
the size of all tables in it) use the following mysql query.

SELECT table_name AS "Table Name",


ROUND(((data_length + index_length) / 1024 / 1024), 2) AS "Size in (MB)"
FROM information_schema.TABLES
WHERE table_schema = "amey"
ORDER BY (data_length + index_length) DESC;

individual schema's size

SELECT table_schema AS "Database Name",


ROUND(SUM(data_length + index_length) / 1024 / 1024, 2) AS "Size in (MB)"
FROM information_schema.TABLES
GROUP BY table_schema;

How to view the database sizes on MB format.


SELECT table_schema "database", sum(data_length + index_length)/1024/1024 "size in
MB" FROM information_schema.TABLES GROUP BY table_schema;

How to view the particular database size on MB format.

SELECT table_schema "database", sum(data_length + index_length)/1024/1024 "size in


MB" FROM information_schema.TABLES WHERE table_schema='amey' GROUP BY table_schema;

find particular table size of the schema

SELECT
TABLE_NAME AS `Table`,
ROUND((DATA_LENGTH + INDEX_LENGTH) / 1024 / 1024) AS `Size (MB)`
FROM
information_schema.TABLES
WHERE
TABLE_SCHEMA = "amey"
AND
TABLE_NAME = "actor"
ORDER BY
(DATA_LENGTH + INDEX_LENGTH)
DESC;

SELECT
TABLE_NAME AS `Table`,
ROUND((DATA_LENGTH + INDEX_LENGTH) / 1024 / 1024) AS `Size (MB)`
FROM
information_schema.TABLES
WHERE
TABLE_SCHEMA = "amey"
ORDER BY
(DATA_LENGTH + INDEX_LENGTH)
DESC;
to find all table size of the database

SELECT
TABLE_SCHEMA AS `Database`,
TABLE_NAME AS `Table`,
ROUND((DATA_LENGTH + INDEX_LENGTH) / 1024 / 1024) AS `Size (MB)`
FROM
information_schema.TABLES
ORDER BY
(DATA_LENGTH + INDEX_LENGTH)
DESC;

show tables; ---> to list out all tables

DELETING USERS
To view a list of all users, type the following command from the mysql> prompt:

SELECT user FROM mysql.user GROUP BY user;


To delete a specific user, type the following command from the mysql> prompt.
Replace username with the name of the user that you want to delete:

DELETE FROM mysql.user WHERE user = 'username';

drop database <db name>; ---> to drop database

Vous aimerez peut-être aussi