5

I've two or more databases in my mysql server. Total memory used by the databases are around 14GB. I want to know, memory used by each database and their tables.

0

4 Answers 4

10

This should work

SELECT table_schema "table name", sum( data_length + index_length ) / 1024 / 1024 "Data Base Size in MB" 
FROM information_schema.TABLES GROUP BY table_schema ; 

It will display the database sizes in two column format => | database name | database size |

Sign up to request clarification or add additional context in comments.

Comments

0

Try following:

SHOW TABLE STATUS LIKE 'TABLENAME'

1 Comment

This I've tried. But I need to get details on a database level. Ex: I've two databases DB1 & DB2, DB1 may be using around 10GB of data & DB2 may be using around 4GB of data. How do I get this result?
0

You can go to this location-

C:\ProgramData\MySQL\MySQL Server 5.5\data\

Under this location u will find the dtabasename folder under which there will be files with the name of the tables, So you can simply right click and check the size of the table on disk.

I hope this is what you were looking for, or you can use:-

 SHOW TABLE STATUS LIKE 'tableName';

Note:- Turn on Show hidden files, i am using engine=MYISAM, i m using C: -drive as my operating system is installed in it.

Comments

0

Use this below query to to verify all the tables data size in MB from single database

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.