SELECT Statment to Determine Total Amount of Data

Posted on 2012-08-10
Last Modified: 2012-08-13
Hello everyone -

I used to have a select statement that I would copy and paste into the MySQL command line client that would return the total amount of data contained within the MySQL server databases.

It included the total data stored in addition to the data size of all indexes, etc.

It was excellent for planning how much space I would need during migrations.

However, I have lost access to that statement.

Would anyone be able to help me formulate a new select statement to address the above?

Thank you very much in advance.

/David C.
Question by:learningtechnologies
    LVL 24

    Accepted Solution

    select table_schema, sum((data_length + index_length)/(1024*1024)) data_size
    from information_schema.tables
    group by table_schema;

    This will give you size per database in MB.   Just adjust if you need to separate the data and index lengths
    LVL 2

    Author Comment


    Thank you very much!

    /David C.
    LVL 2

    Author Closing Comment

    Perfect! Exactly what I needed. Thank you!

    Featured Post

    Find Ransomware Secrets With All-Source Analysis

    Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

    Join & Write a Comment

    Loading csv or delimited data files to MySQL database is a very common task frequently questioned about and almost every time LOAD DATA INFILE comes to the rescue. Here we will try to understand some of the very common scenarios for loading data …
    Both Easy and Powerful How easy is PHP? (  Very easy.  It has been described as "a programming language even my grandmother can use." How powerful is PHP?  http://en.wikiped…
    This video discusses moving either the default database or any database to a new volume.
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

    728 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now