I'm trying to find out the exact size of one column within a table. PHPMyAdmin doesn't show size of columns, only the tables.
Any way I can get the size of the column?
Thankyou
This can be accomplished easily with the following query: SELECT TABLE_SCHEMA AS `Database`, TABLE_NAME AS `Table`, ROUND((DATA_LENGTH + INDEX_LENGTH) / 1024 / 1024) AS `Size (MB)` FROM information_schema.
Suppose we square column, so area of square =a2, hence a2 = 54925mm2, a=√54925mm2=234mm, width and depth of column =234mm×234mm, taking in round figure=230mm×300mm(9″×12″) for rectangular column.
You can get the MySQL table columns data type with the help of “information_schema. columns”. SELECT DATA_TYPE from INFORMATION_SCHEMA. COLUMNS where table_schema = 'yourDatabaseName' and table_name = 'yourTableName'.
I would recommend that you consider using CHAR_LENGTH() instead of LENGTH(). CHAR_LENGTH() returns the length of a string in characters. LENGTH() returns its length in bytes. For multi-byte character sets these values can be different, and you are probably concerned with character length, not byte length.
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))/1024 
FROM TABLE_NAME;
                        SELECT column_name, 
       character_maximum_length 
FROM   information_schema.columns 
WHERE  table_schema = Database() 
       AND -- name of your database 
       table_name = 'turno' 
       AND -- name of your table 
       column_name = 'nombreTurno' -- name of the column 
If you wanna Whole Table size then use this
SELECT table_name                                                 AS "Tables", 
       Round(( ( data_length + index_length ) / 1024 / 1024 ), 2) "Size in MB" 
FROM   information_schema.tables 
WHERE  table_schema = "$db_name" 
ORDER  BY ( data_length + index_length ) DESC; 
Edit
SELECT column_name, 
       character_maximum_length 
FROM   information_schema.columns 
WHERE  table_schema = 'websi_db1' 
       AND table_name = 'thread' 
       AND column_name = 'title' 
Source
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With