DB2中的转义字符

1、数据库脚本

CREATE TABLE OLIVER_11(ID INT,VALUE VARCHAR(100));

INSERT INTO OLIVER_11 VALUES(1,'20%');

INSERT INTO OLIVER_11 VALUES(2,'OLIVER_QIN');

INSERT INTO OLIVER_11 VALUES(3,'AA''')

2、以下是DB2的转义字符

2.1 对“%”的转义

SELECT * FROM OLIVER_11 WHERE VALUE LIKE '%!%%' ESCAPE '!'

2.2 对"_"下划线的转义

SELECT * FROM OLIVER_11 WHERE VALUE LIKE '%!_%' ESCAPE '!'

2.3对“'”(单引号)的转义

SELECT * FROM OLIVER_11 WHERE VALUE LIKE '%''%'

2.4含有字符串拼接的单引号转义

SELECT VALUE||''||'_YUE'||'' FROM OLIVER_11 WHERE VALUE LIKE '%!_%' ESCAPE '!'

 

posted @ 2016-09-14 17:05  OLIVER_QIN  阅读(9628)  评论(0编辑  收藏  举报