0

I have a table in MySQL as Applicant(Applicant_ID, Name), Applicant_ID is of type bigint. The table is already populated with data. Now I need to change the datatype of Applicant_ID to char/varchar? How to do that by converting my existing data into varchar and without loosing any data from the table?

  • select CONVERT(id, CHAR(50)) as colI1 from t9; look here: http://stackoverflow.com/questions/15368753/cast-int-to-varchar – IgorM May 13 '17 at 18:25
  • You should be ok going from `bigint` to `char/varchar` according to the doc - https://dev.mysql.com/doc/refman/5.7/en/alter-table.html#alter-table-column. It does say - "When you change a data type using CHANGE or MODIFY, MySQL tries to convert existing column values to the new type as well as possible." - probably if your `_ID` field contains a reasonable number range. – DaveStSomeWhere May 13 '17 at 18:26
  • 1
    This sounds like a really bad, and really unnecessary, idea – Strawberry May 13 '17 at 18:54

0 Answers0