Finding the size of all columns in a table

Greetings
Is there a query to find all the columns and size of each one in a table in mysql :smile:

Thank you

Hi @Dba1
If you are looking to gather information about your schema such as max char limits and column names + types, you can use INFORMATION_SCHEMA.COLUMNS, for example:

SELECT 
    table_schema,
    table_name,
    column_name,
    data_type,
    character_maximum_length
FROM
    information_schema.columns
WHERE
    table_schema NOT IN ('information_schema' , 'performance_schema', 'sys');

1 Like

Thanks you for your reply
basically I’m looking to find out the size of a particular field(column_name). I have a column with a “BLOB” data type, I’m trying to find out if the size of this column is causing the sudden increase we are seeing in the table.

Thank you

Note

2 Likes

Hi @Dba1 sorry about the tardy reply, I didn’t see this in my inbox until now :frowning:

You can use something like the LENGTH() function:

SELECT LENGTH(`MY_BLOB_COLUMN`) FROM my_table ORDER BY LENGTH(`MY_BLOB_COLUMN`) DESC;
2 Likes