简体   繁体   中英

MySQL: turn enum to tinyint

I have table with column that is enum with possible values 'Y' or 'N'. I want to set that to tinyint and convert all rows accordingly - set 'Y' to 1, and 'N' to 0. Could you please explain how to do that. Thanks

  1. Add options 0 and 1 to the ENUM.
  2. Run QUERY (UPDATE [table] SET [column] = 1 WHERE [column] = 'Y') (and also for 'N')
  3. Change type to INT(1)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM