I am looking to replace values in a particular column. For example the following column values
我希望替换特定列中的值。例如下面的列值。
column name
----------
Test1
Test2
Test3
Test12
should be (replacing est1
with rest1
)
应该是(用rest1替换est1)
column name
----------
Trest1
Test2
Test3
Trest12
4 个解决方案
#1
143
Use REPLACE:
使用替换:
SELECT REPLACE(t.column, 'est1', 'rest1')
FROM MY_TABLE t
If you want to update the values in the table, use:
如果要更新表中的值,请使用:
UPDATE MY_TABLE t
SET column = REPLACE(t.column, 'est1', 'rest1')
#2
18
If you need to update the value in a particular table:
如果您需要更新特定表中的值:
UPDATE TABLE-NAME SET COLUMN-NAME = REPLACE(TABLE-NAME.COLUMN-NAME, 'STRING-TO-REPLACE', 'REPLACEMENT-STRING');
where
在哪里
TABLE-NAME - The name of the table being updated
COLUMN-NAME - The name of the column being updated
STRING-TO-REPLACE - The value to replace
REPLACEMENT-STRING - The replacement
#3
-1
In Oracle, there is the concept of schema name, so try using this
在Oracle中,有模式名的概念,所以尝试使用它。
update schemname.tablename t
set t.columnname = replace(t.columnname, t.oldvalue, t.newvalue);
#4
-2
I'm using Version 4.0.2.15 with Build 15.21
我在构建15.21中使用4.0.2.15版本
For me I needed this:
我需要这个:
UPDATE table_name SET column_name = REPLACE(column_name,"search str","replace str");
Putting t.column_name
in the first argument of replace
did not work.
将t。在replace的第一个参数中,column_name不工作。
#1
143
Use REPLACE:
使用替换:
SELECT REPLACE(t.column, 'est1', 'rest1')
FROM MY_TABLE t
If you want to update the values in the table, use:
如果要更新表中的值,请使用:
UPDATE MY_TABLE t
SET column = REPLACE(t.column, 'est1', 'rest1')
#2
18
If you need to update the value in a particular table:
如果您需要更新特定表中的值:
UPDATE TABLE-NAME SET COLUMN-NAME = REPLACE(TABLE-NAME.COLUMN-NAME, 'STRING-TO-REPLACE', 'REPLACEMENT-STRING');
where
在哪里
TABLE-NAME - The name of the table being updated
COLUMN-NAME - The name of the column being updated
STRING-TO-REPLACE - The value to replace
REPLACEMENT-STRING - The replacement
#3
-1
In Oracle, there is the concept of schema name, so try using this
在Oracle中,有模式名的概念,所以尝试使用它。
update schemname.tablename t
set t.columnname = replace(t.columnname, t.oldvalue, t.newvalue);
#4
-2
I'm using Version 4.0.2.15 with Build 15.21
我在构建15.21中使用4.0.2.15版本
For me I needed this:
我需要这个:
UPDATE table_name SET column_name = REPLACE(column_name,"search str","replace str");
Putting t.column_name
in the first argument of replace
did not work.
将t。在replace的第一个参数中,column_name不工作。