我在oracle中遇到了以下语法来创建过程。我想知道语法中使用的是什么',q'a,q'z和z'。
有人可以解释这些结构的用法。
**
viewControllers
**
注意:语法可能不完整。
答案 0 :(得分:1)
此语法用于将引号之间的字符串处理为写入的位置;您决定要用作分隔符的字符,然后在字符串的开头和结尾使用它;一些例子:
select 'quote here: ''' , 'double quote'from dual union all
select q'@quote here: ''@', 'q syntax, double quote means two quotes' from dual union all
select q'@quote here: '@', 'q syntax, no need fou double quotes' from dual union all
select 'two quotes here: ''''', 'same thing to have two quotes' from dual union all
select q'@two quotes here: ''@', 'and two quotes with q syntax ' from dual union all
select q'@this is the delimiter char: @.@', 'the delimiter character can be used wherever in the string' from dual union all
select q'@@delimiter is in the beginning and in the end@@', 'you have to double the delimiter if you want it in the end or beginning' from dual
您可以查看文档here
答案 1 :(得分:0)
Q' '是一种使用嵌入式引号引用字符串文字的方法
e.g。
select q'x It's a string x' From dual;
It's a string
语法是q' [...]',其中" ["和"]"是字符a'和z'在你的例子中。因此select q'z execute immediate q'a SELECT count(1) from dual a'z' from dual
变为execute immediate q'a SELECT count(1) from dual a'
在示例查询下方
-- quoting string literals (new from 10G)
select q'aIt's string with embedded quotesa' from dual -- string terminated by chacter "a"
union all
select 'It''s string with embedded quotes' from dual--quotes using a 2 quotes
union all
select q'z execute immediate q'a SELECT count(1) from dual a'z' from dual ; -- your example