Oracle allows the assignment of special escape characters to the reserved characters in Oracle can be escaped to normal characters that is interpreted literally, by using ESCAPE keyword.
For example, to select the name of guests with _ (underscore) in it, use the following statement:
SELECT guest_name FROM guest_table WHERE name LIKE '%\_%' ESCAPE '\';
Without specifying the \ (backslash) as escape clause, the query will return all guest names, making the unwanted results problem.
The above syntax will not work on ‘ (quote). To escape this quotation mark and to display the quote literally in string, insert another quote (total 2 quotes) for every quote that want to be displayed. For example:
SELECT 'This will display line with quote''s word.' FROM temp_table;
SELECT 'This will display ''''double quoted'''' word.' FROM temp_table;
will return the following respectively:
This will display line with quote’s word.
This will display ”double quoted” word.