2012-03-22 19 views
1

私はデータベースを持っており、テーブルにはカラムの値を変更する必要があります。別の開発者。私はcreditsというテーブルとcredit_typeというカラムを持っています。mySQL - 'short'を 'long'に、 'long'を 'short'に変更する方法

credit_typeの値は、longshortの2つです。

longの値をすべてshortに置き換えて、shortの値をすべてlongと読み替えるにはどうすればよいですか?

答えて

3
update credits set credit_type = 'interim' where credit_type = 'long'; 
update credits set credit_type = 'long' where credit_type = 'short'; 
update credits set credit_type = 'short' where credit_type = 'interim'; 

完全な信頼性のためにトランザクションですべてをラップします。

関連する問題