sql - How to enter special characters like “\” in oracle database INSERT STATEMENT? -
update: i've figured out problem wasn't coming backslash. problem single quotation mark problem. i'm trying insert words apostrophes, , whenever there 1 in list, apostrophe treated single quotation mark. oracle adding backslash automatically though didn't have 1 in original insert values.
example:
insert dictionnaire (mot) values ('s\'ensuivre');
was originally
insert dictionnaire (mot) values ('s'ensuivre');
is there way treat apostrophe differently single quotations surrounding values?
original question:
i want insert backslash string:
insert dictionnaire (mot,definition) values ('abasourdir','v. tr.\\n ahurir.');
is there way prevent backslash doing does, is: "escaping single character or symbol", , have dbms treat simple string?
set define off; doesn't work.
thanks!
i want insert backslash string: insert dictionnaire (mot,definition) values ('abasourdir','v. tr.\n ahurir.');
backslash work escape character if set escape character backslash, or use escape command in individual sql statement. lest should able insert other character.
use two backslashes instead of single backslash.
for example, have set escape character set escape '\':
sql> create table t(a number, b varchar2(10)); table created. sql> sql> set escape '\' sql> sql> insert t values(1, '\\'); 1 row created. sql> insert t values(2, '\\n'); 1 row created. sql> sql> select * t; b ---------- ---------- 1 \ 2 \n sql>
is there way prevent backslash doing does, is: "escaping single character or symbol", , have dbms treat simple string?
then don't use backslash escape. set any other character escape character.
for example, use forward slash escape character instead of backslash:
sql> drop table t purge; table dropped. sql> sql> create table t(a number, b varchar2(10)); table created. sql> sql> set escape '/' sql> sql> insert t values(1, '\'); 1 row created. sql> insert t values(2, '\n'); 1 row created. sql> insert t values(2, '/n'); 1 row created. sql> sql> select * t; b ---------- ---------- 1 \ 2 \n 2 n sql>
so, can see, forward slash used escape, not backslash.
for matter, use other character escape well:
sql> set escape '#' sql> sql> insert t values(1, '\'); 1 row created. sql> insert t values(2, '\n'); 1 row created. sql> insert t values(2, '#n'); 1 row created. sql> sql> select * t; b ---------- ---------- 1 \ 2 \n 2 n sql>
so, can see '#'
used escape character. backslash had no affect.
Comments
Post a Comment