Replace row in column using query in Oracle

In one of my oracle tables in one column of each row there is a line "House name". I need to replace it with the House Number. Can I fulfill the update request to find and replace this row in all rows.Or is there a built-in function for this.

+4
source share
2 answers

The following of online technology can help:

REPLACE ("The username of the house is ABC", "House Name", "House Number");

will return 'User House Number is ABC'

REPLACE ('123tech123', '123'); will return 'tech'

REPLACE ('222tech', '2', '3'); will return '333tech'

REPLACE ('0000123', '0'); will return '123'

REPLACE ("House Name", "House Name", "House Number"); home number will return

+4
source

Just do:

UPDATE <TABLE-NAME> SET <COLUMN-NAME> = 'House Number' WHERE <COLUMN_MAME> = 'House Name' 

This, of course, will only work if the column contains only this row. Otherwise, you should use the replace function, as Fayeq pointed out, in your update statement above

 UPDATE <TABLE-NAME> SET <COLUMN-NAME> = REPLACE('House Name', 'Name', 'Number') WHERE <COLUMN_MAME> = 'House Name' 

EDIT :

You can omit the WHERE if all rows contain the same row (house number)

+4
source

Source: https://habr.com/ru/post/1500872/


All Articles