Oracle Wildcard Characters
Version 18.3.0.1

General Information
Library Note Morgan's Library Page Header
Coming to OpenWorld 2018? Be sure to visit the TidalScale booth in Moscone South and learn how to solve performance problems and lower costs with Software Defined Servers. Before you visit the booth, or if you can't make it this year, check out TidalScale at www.tidalscale.com. Be sure to click on the Solutions link and look through the Oracle resources.
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
Built-in Functions
Built-in Packages
DELETE Statements
DML Statements
INSERT Statements
MERGE Statements
SELECT Statements
UPDATE Statements
WHERE Clause
What's New In 12cR2
What's New In 18cR1