HOW TO GET A SIZE OF COLUMN IN MYSQL

  • AUTHOR: // CATEGORY: Development, mySQL, Open Source

    No Comments

    So last week I got an email from our host saying a database has received its maximum size of 3GB. I was like what? How? So I quickly ran the below to check which column was causing the problem.

    If you want to find out the size of column=COLUMN_NAME from table=TABLE_NAME, you can always run a query like this:

    SELECT sum(char_length(COLUMN_NAME))FROM TABLE_NAME;
    
    

    Size returned is in bytes. If you want it in kb, you could just divide it by 1024, like so:

    SELECT sum(char_length(COLUMN_NAME))/1024FROM TABLE_NAME;

    Happy querying.

COMMENTS

0 Responses to How to get a size of column in mySQL

LEAVE A REPLY

This site uses Akismet to reduce spam. Learn how your comment data is processed.