What will happen if I change the type of a column from int to year?

Posted by MachinationX on Stack Overflow See other posts from Stack Overflow or by MachinationX
Published on 2010-04-14T21:19:15Z Indexed on 2010/04/14 21:23 UTC
Read the original article Hit count: 177

Filed under:
|
|

I have a table in MySQL 4.0 which currently has a year field as a smallint(6) type. What will happen if I convert it directly to a Year type with a query like the following:

ALTER TABLE t MODIFY y YEAR(4) NOT NULL DEFAULT CURRENT_TIMESTAMP;

When the current members of column y have values like 2010? I assume that because the year type is technically values from 1-255, values above that will be truncated or broken.

So if MySQL isn't smart enough to realize that 2010(int) = 110(year), what would be the simplest query or queries to convert the values?

Thanks for your help!

© Stack Overflow or respective owner

Related posts about mysql

Related posts about database