Oracle Wildcard Characters
Version 12.1.0.2

General Information
Library Note Morgan's Library Page Footer
The Library is currently in the process of being upgraded from Oracle Database Version 12.1.0.2 to 12.2.0.1. Also important ... there are rumors on the web about SPARC and Solaris being discontinued. Welcome to the age of fake news. There is absolutely not a byte of truth to these irresponsible rumors.
Purpose Make possible fuzzy search criteria in the SELECT statement's WHERE clause
 
Demo Table And Records
Demo Data conn uwclass/uwclass@pdbdev

CREATE TABLE wildcard (
test VARCHAR2(25));

INSERT INTO wildcard VALUES ('23%45');
INSERT INTO wildcard VALUES ('2345');
INSERT INTO wildcard VALUES ('2365');
INSERT INTO wildcard VALUES ('Daniel Morgan');
INSERT INTO wildcard VALUES ('Washington');
COMMIT;
SELECT *
FROM wildcard
WHERE test LIKE '%\%%' ESCAPE '\';
Wildcard Characters
Single Character _ (underscore)
SELECT *
FROM wildcard
WHERE test LIKE '23_5';
Multiple Characters % (percentage sign)
SELECT *
FROM wildcard
WHERE test LIKE '2%5';
Mixed Single And Multiple Characters SELECT *
FROM wildcard
WHERE test LIKE '_3%5';
Complex Statement SELECT *
FROM wildcard
WHERE test LIKE '%a%a %';
 
Querying Records Containing Wildcards
Find Records Containing Percentage Sign ESCAPE '<escape_character>'
SELECT *
FROM wildcard
WHERE test LIKE '%\%%' ESCAPE '\';
Find values beginning with an underscore character ESCAPE '<escape_character>'
SELECT x.ksppinm NAME, y.ksppstvl VALUE, x.ksppdesc DESCRIPTION
FROM x$ksppi x, x$ksppcv y
WHERE x.inst_id = userenv('Instance')
AND y.inst_id = userenv('Instance')
AND x.indx = y.indx
AND x.ksppinm like '\_b%' ESCAPE '\'
ORDER BY 1

Related Topics
DELETE Statements
DML Statements
INSERT Statements
MERGE Statements
SELECT Statements
UPDATE Statements
WHERE Clause