I have mysql database with following table...
| id | amount | tax |
+----+---开发者_如何转开发-----+-----+
| 1 | 500 | |
+----+--------+-----+
| 2 | 100 | |
+----+--------+-----+
I have to delete amount column but before doing that i want to shift all data of amount row from amount row to tax row. How can it be done using mysql query? Please help.
UPDATE mytable SET tax = amount
after you can remove it
ALTER TABLE mytable DROP COLUMN amount;
update TABLE_NAME set tax=amount;
will do.
UPDATE yTable SET tax = amount
Or to rename instead of copying (much faster):
ALTER yTable CHANGE amount tax YOURDATATYPE;
Delete tax before renaming.
update your_table_name set tax=amount
you can delete the column data
UPDATE your_table_name SET amount = NULL WHERE amount is not null;
or you can delete column itself
ALTER TABLE your_table_name DROP COLUMN amount
精彩评论