MySQL converting Text to Varchar

One incentive of converting a text column to a varchar column is that, you can index that column for quicker query.

Before converting, you want to make sure you won’t be truncating anything. Run the following to make sure

SELECT MAX( LENGTH(  target_column ) ) 
FROM  target_table

As long as the returned length is less than your varchar length, you are good to go.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s