I have a table with 50+ VARCHAR(255) columns.
The moderators report that some of the content is cut of after 250 characters in few of the fields.
As checked this is expected behavior for
VARCHAR(255) and I have to update some of the fields to
text. But the problem is they can not give me details/instruction which fields are making problems ..
So my best guess is to analyse the current data and find the columns that usually store long content.
Is there a good query structure I can use to get:
- AVG length for each column.
- Max length for each column.
- Count of rows with length 200+ for this column.
SELECT AVG(CHAR_LENGTH(col)) avg_length MAX(CHAR_LENGTH(col)) max_length COUNT(CASE WHEN CHAR_LENGTH(col) >= 200 THEN 1 ELSE NULL END) 200_plus_count FROM tbl;