如何执行查询[选择'我正在寻找学习指南1Z0-071,1Z0-146,1Z0-148!'来自双重身份?

时间:2018-05-24 05:34:56

标签: sql oracle oracle11g

我正在尝试编写查询,但收到错误:

SQL*Plus: Release 11.2.0.1.0 Production on Thu May 24 11:24:48 2018
Copyright (c) 1982, 2010, Oracle.  All rights reserved.
Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options

SQL> select 'I'm Looking for study guides 1Z0-071, 1Z0-146, 1Z0-148!' from dual;
  

错误:       ORA-01756:引用的字符串未正确终止

1 个答案:

答案 0 :(得分:0)

您可以使用quoting string literal

enter image description here

select q'{I'm Looking for study guides 1Z0-071, 1Z0-146, 1Z0-148!}'
from dual;

<强> DBFiddle Demo

这种机制非常有用,特别是在生成大量动态SQL时,可以避免所有笨拙的'''''