views:

163

answers:

3

I'm using an old table, which has a varchar(40) field in it. I want it to be possible to insert more characters in that field, so I want to increase the length of it.
Are there possible negative consequences I should think of before increasing the length?

A: 

If you have set the length of 40 but if you try insert more chars, then all will be rejected resulting in empty field value. You should provide the upper length value that you are expected to enter for that field.

Sarfraz
How does this answer relate to the question? Except for using some of the same terms.
Joey
Sarfraz Ahmed: You've probably misunderstood my question. I already have a field with a length of 40, but that's not enough space, so I want to increase it. Are there possible consequenses of increasing the length.
Robin
+3  A: 

Increasing should typically not cause issues, it is the decreasing that can cause problems.

astander
By saying typically, you mean that there are situations where there could be issues? Situations like what?
Robin
Well, it might depend on what you are doing with that column. For example the client or some stored procedure might try storing it in another column of another table which suddenly got too small. Such dependencies are sometimes hard to find.
Joey
Depending on the version of MySql, and Collation, the version might contain bugs. Also, I do not know how this might affect the paging of stored data or Indexing, and references to this column from SPs, etc.
astander
+1  A: 

Changing the declared size of a varchar field should not require the existing data to be modified.

Note that changing the size of char or number field will require MySQL to update every affected value to the new type. Changing such fields or adding columns may result in the DBMS having to rewrite the entire table in order to accomodate a larger row size depending on whether there is any redundant space at the row level. This can take some time on a large table.

Make sure that you update any other tables which join to this column too!

HTH

C.

symcbean