开发者

SQL Update or Replace function?

开发者 https://www.devze.com 2023-03-18 01:27 出处:网络
I have a ta开发者_运维问答ble which contains multiple columns. Column 1Column 2Column 3 unique identifieralphanumerical valuenumerical value

I have a ta开发者_运维问答ble which contains multiple columns.

Column 1                  Column 2                   Column 3
unique identifier         alphanumerical value       numerical value

The unique identifier is currently using the values from Column 2. If I wanted to use the values from Column 3 instead, which would be better suited for my situation? Replace or Update? Or is there another way I should go about doing this.

I'm using TOAD for Oracle for what it is worth.

Thank you.


Turns out what the OP wanted to do was simply set column1 to the value in column3, no replace was necessary. Just a straight update, as in:

UPDATE TheTable SET column1 = column3;


IF you want to make a change in the table THEN use UPDATE ELSE IF you want to just view the column1 values mapped with column3 values for particular instance THEN use INSERT

The otherway around use UPDATE to change the contents of table, whereas replace is a function which really doesnt makes any changes in the contents of the table but just shows u the changed output.


You would use both.

update sometable set column1 = replace(column1,column2,column3)

You might want to do the following first to make sure you're replacing what you want to replace:

select replace(column1,column2,column3) from sometable
0

精彩评论

暂无评论...
验证码 换一张
取 消