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
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
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'
If you are doing this from a script, you can run this after you have established a connection (and hence the database is already selected):
SELECT character_maximum_length
FROM information_schema.columns
WHERE table_name = ? AND column_name = ?
Replace the ?'s with the name of your table and the name of your column, respectively.