Xameer
Xameer

Reputation: 31237

How long is too long data for any column in MySql

I was trying to insert some string values to a column column1 in mysql table using C#.

The values can keep changing every time.

Sometimes the application throws Data too long exception.

I went through some posts:

But my question is:

How can I programmatically decide how long string (or other data type) value is too long for a mysql column.

So that if the data is too long and cannot be inserted, I can manually truncate less useful data.

Upvotes: 0

Views: 756

Answers (1)

davejal
davejal

Reputation: 6133

This is done in your db. The database structure tells you what is to long. The errors you're getting are coming from the database.

So the decision is when the database was created.

  1. either change the database or
  2. check the structure of the database to consult yourself what limits are set
  3. change the code accordingly

Update As you question changed:

To truncate your data, see step 2 from above, use that info to truncate.

Upvotes: 1

Related Questions