Reputation: 19
I have millions of records in a table and I need to update particular records which have wrong values. How do I do it?
Example:
Si Item_Id
1 T21547856
2 T45200254
3 T54785000
Need to update like:
T21547856 = CS2541
T54785000 = CS5475
This is just an example. I have millions of records and need to update more than half a million.
Upvotes: 0
Views: 288
Reputation: 17643
One approach would be:
Create an index on item_id, then just do the updates. update table set item_id = 'CS2541' where itme_id = 'T21547856'
This works only item_ids are unique in your table.
After this, you may drop the index if you don't need it.
A second approach would be to create another table, B, with values to be updated:
si item_id
1 CS2541
3 CS5475
Then do a merge
:
merge into your_table a
using b
on a.si=b.si
when matched then update set a.item_id=b.item_id;
Upvotes: 1