文档中心MogDBMogDB StackUqbar
v5.0

文档:v5.0

支持的版本:

其他版本:

支持q quote转义字符

可获得性

本特性自MogDB 5.0.0版本开始引入。

特性简介

本特性兼容Oracle中,使用q'对单个字符串进行全局单引号转义的用法,例如SELECT q'{I'm fine}';

客户价值

增强MogDB与Oracle的兼容性,减少应用程序的迁移代价。

特性约束

  • 由于jdbc本地字符检查的原因,当前暂时不支持jdbc执行该命令。

语法描述

该语法为一个字母q(不分大小写),一个单引号,一个定界符,字符串原文,一个定界符,一个单引号。

img

q'转义符通常后面使用! [] {} () <>等转义符号作为定界符,也可以使用\ ,也可以用字母、数字、=、+、-、*、&、$、%、#等,不可以使用空格,tab键。

定界符不可以为非英文、非数字、非特殊字符。如果中间字符串中包含定界符,需要确保定界符后面不是单引号。

定界符的范围包括特殊符号、英文字符、数字。

特殊字符:{},',:,|,[],,|,<>,?,=,+,-,_,(),*,&,^,%,$,#,@,!,~,`,.,/, 包括逗号,双引号",单引号'

例如:SELECT q'{I'm }' fine}'使用{作为定界符,但是中间的字符串包含}并且后面跟着单引号,该语法不支持转义。

示例

SELECT q '{I'm fine}';
 ?column? 
----------
 I 'm fine
( 1 row)
 
SELECT q ''I'm fine'';
 ?column? 
----------
 I 'm fine
( 1 row)
 
SELECT q '[I'm fine]';
 ?column? 
----------
 I 'm fine
( 1 row)
 
SELECT q '\I'm fine\';
 ?column? 
----------
 I 'm fine
( 1 row)
 
SELECT q '<I'm fine>';
 ?column? 
----------
 I 'm fine
( 1 row)
 
SELECT q '?I'm fine?';
 ?column? 
----------
 I 'm fine
( 1 row)
 
SELECT q 'aI'm finea';
 ?column? 
----------
 I 'm fine
( 1 row)
 
SELECT q '2I'm fine2';
 ?column? 
----------
 I 'm fine
( 1 row)
 
SELECT q '=I'm fine=';
 ?column? 
----------
 I 'm fine
( 1 row)
 
SELECT q '-I'm fine-';
 ?column? 
----------
 I 'm fine
( 1 row)
 
SELECT q '(I'm fine)';
 ?column? 
----------
 I 'm fine
( 1 row)
 
SELECT q '*I'm fine*';
 ?column? 
----------
 I 'm fine
( 1 row)
 
SELECT q '&I'm fine&';
 ?column? 
----------
 I 'm fine
( 1 row)
 
SELECT q '^I'm fine^';
 ?column? 
----------
 I 'm fine
( 1 row)
 
SELECT q '%I'm fine%';
 ?column? 
----------
 I 'm fine
( 1 row)
 
SELECT q '$I'm fine$';
 ?column? 
----------
 I 'm fine
( 1 row)
 
SELECT q '#I'm fine#';
 ?column? 
----------
 I 'm fine
( 1 row)
 
SELECT q '@I'm fine@';
 ?column? 
----------
 I 'm fine
( 1 row)
 
SELECT q '!I'm fine!';
 ?column? 
----------
 I 'm fine
( 1 row)
 
SELECT q '~I'm fine~';
 ?column? 
----------
 I 'm fine
( 1 row)
 
SELECT q '`I'm fine`';
 ?column? 
----------
 I 'm fine
( 1 row)
 
SELECT q '{'s is good}';
  ?column?  
------------
  's is good
( 1 row)
 
SELECT q '''s is good'';
  ?column?  
------------
  's is good
( 1 row)
 
SELECT q '['s is good]';
  ?column?  
------------
  's is good
( 1 row)
 
SELECT q '\'s is good\';
  ?column?  
------------
  's is good
( 1 row)
 
SELECT q '<'s is good>';
  ?column?  
------------
  's is good
( 1 row)
 
SELECT q '?'s is good?';
  ?column?  
------------
  's is good
( 1 row)
 
SELECT q 'a's is gooda';
  ?column?  
------------
  's is good
( 1 row)
 
SELECT q '2's is good2';
  ?column?  
------------
  's is good
( 1 row)
 
SELECT q '='s is good=';
  ?column?  
------------
  's is good
( 1 row)
 
SELECT q '-'s is good-';
  ?column?  
------------
  's is good
( 1 row)
 
SELECT q '('s is good)';
  ?column?  
------------
  's is good
( 1 row)
 
SELECT q '*'s is good*';
  ?column?  
------------
  's is good
( 1 row)
 
SELECT q '&'s is good&';
  ?column?  
------------
  's is good
( 1 row)
 
SELECT q '^'s is good^';
  ?column?  
------------
  's is good
( 1 row)
 
SELECT q '%'s is good%';
  ?column?  
------------
  's is good
( 1 row)
 
SELECT q '$'s is good$';
  ?column?  
------------
  's is good
( 1 row)
 
SELECT q '#'s is good#';
  ?column?  
------------
  's is good
( 1 row)
 
SELECT q '@'s is good@';
  ?column?  
------------
  's is good
( 1 row)
 
SELECT q '!'s is good!';
  ?column?  
------------
  's is good
( 1 row)
 
SELECT q '~'s is good~';
  ?column?  
------------
  's is good
( 1 row)
 
SELECT q '`'s is good`';
  ?column?  
------------
  's is good
( 1 row)
Copyright © 2011-2024 www.enmotech.com All rights reserved.