Oracle Study Notes: update field includes single quotes

Usually, when a direct update changes within a field, for example:

update table_temp set name = 'Hider' where id = 100;

However, the updated value is included in single quotation marks, can not be updated in the above manner, it will be given.

Then test it.

-- 建立测试表
create table temp_cwh_test_1219
(
  id varchar2(10),
  name varchar2(20)
);

-- 插入数据
insert into temp_cwh_test_1219 values (1,'Nick');
insert into temp_cwh_test_1219 values (2,'Tom');

-- 更新数据
update temp_cwh_test_1219 set name = '''xxxx''' where id = 1;
-- 1    1   'xxxx'
-- 2    2   Tom

-- 删除测试表
drop table temp_cwh_test_1219;

Effect as expected.

Principle : simply replace the single quotation marks to be inserted or updated content for the two single quote.

Guess you like

Origin www.cnblogs.com/hider/p/12070676.html