Oracle - Making use of special characters

December 2016




Intro


For some SQL queries, we need to search for strings containing special characters like '%'.
  • Considering the below example, the need is to find records containing the middle character '%':


Select *  
From table  
where fields like '%%%'; 

Solution

  • To do this you must know how to seperate the special characters.
  • First of all we must give a value to SQL ESCAPE parameter, for example '^':

SQL>SET ESCAPE ^
  • From there, the character '^' can be used to identify and seperate special characters.



Select *  
From table  
where fields like '%^%%';

Related :

This document entitled « Oracle - Making use of special characters » from CCM (ccm.net) is made available under the Creative Commons license. You can copy, modify copies of this page, under the conditions stipulated by the license, as this note appears clearly.