开发者

How to handle a single quote in Oracle SQL

开发者 https://www.devze.com 2022-12-30 20:18 出处:网络
How do I insert a record in a column having varchar data type having single quote in it? Example: first name is ROBERT and last name is D\'开发者_运维问答COSTAUse two single-quotes

How do I insert a record in a column having varchar data type having single quote in it?

Example: first name is ROBERT and last name is D'开发者_运维问答COSTA


Use two single-quotes

SQL> SELECT 'D''COSTA' name FROM DUAL;

NAME
-------
D'COSTA

Alternatively, use the new (10g+) quoting method:

SQL> SELECT q'$D'COSTA$' NAME FROM DUAL;

NAME
-------
D'COSTA


I found the above answer giving an error with Oracle SQL, you also must use square brackets, below;

SQL> SELECT Q'[Paddy O'Reilly]' FROM DUAL;


Result: Paddy O'Reilly

0

精彩评论

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

关注公众号