Daily Archives: 06.06.2022
How to safely update data in MySQL
1 2 3 4 5 6 7 8 |
CREATE TABLE IF NOT EXISTS my_tmp_copy LIKE my; INSERT INTO my_tmp_copy SELECT * FROM my; UPDATE my_tmp_copy SET order_count = 5 WHERE customer_id > 0; RENAME TABLE my TO my_old, my_tmp_copy TO my; |