For this setup the plain old LIKE
works fine. You need not even care about the new line charactes.
where column1 LIKE '%<sql>%xyz%</sql>%'
will do the job.
For a case insensitive search add LOWER
where LOWER(column1) LIKE '%<sql>%xyz%</sql>%'
For a context delimiter search, e.g. whole word search simple replace all relevant white space characters to blank:
where replace(replace(lower(column1),CHR(10),' '),CHR(9),' ') LIKE '%<sql>% xyz %</sql>%';
Here I'm replacing new line and tab, feel free to add other, e.g. CHR(13) if required.
General rule is - if you may use LIKE
prefer it to REGEXP
as the performance of LIKE
is much better.
Simple demo:
create table MYTABLE(column1 varchar2(1000))
;
insert into MYTABLE(column1) values('bla bla <sql> bla'||chr(10)||' xyz bla </sql> bla');
insert into MYTABLE(column1) values('bla bla <sql> bla'||chr(10)||' NO MACTH bla </sql> bla');
commit;
select * from MYTABLE;
COLUMN1
-------------------
bla bla <sql> bla
xyz bla </sql> bla
bla bla <sql> bla
NO MACTH bla </sql> bla
select * from MYTABLE
where column1 LIKE '%<sql>%xyz%</sql>%';
COLUMN1
-------------------
bla bla <sql> bla
xyz bla </sql> bla