1.两个通配符
字符匹配操作可以使用通配符 “%” 和 “_”:
%:表示任意个字符,包括零个;
_:表示一个任意字符;
2.预备工作sqlplus
Connected to aspx?tid=12” target=”_blank” title=”Oracle”>Oracle Database 11g Enterprise Edition Release 11.2.0.1.0
Connected as scott
SQL> select * from dept;
DEPTNO DNAME LOC
10 ACCOUNTING NEW YORK
20 RESEARCH DALLAS
30 SALES CHICAGO
40 OPERATIONS BOSTON
3.“%” 和 “_”演示:
SQL> select * from dept where DNAME like ‘_A%’;
DEPTNO DNAME LOC
30 SALES CHICAGO
3.ESCAPE 演示
SQL> insert into dept values(50,’BEIJING’,’HE%BEI’);
1 row inserted
SQL> select * from dept;
DEPTNO DNAME LOC
10 ACCOUNTING NEW YORK
20 RESEARCH DALLAS
30 SALES CHICAGO
40 OPERATIONS BOSTON
50 BEIJING HE%BEI
SQL> select * from dept where loc like ‘%\%%’ escape ‘\’;
DEPTNO DNAME LOC
50 BEIJING HE%BEI
SQL> select * from dept where loc like ‘%e%%’ escape ‘e’;
DEPTNO DNAME LOC
50 BEIJING HE%BEI
版权声明
author :shaoduo
原文来自:http://blog.youkuaiyun.com/shaoduo/article/details/69220347
其他出处均为转载,原创作品欢迎读者批评指正