Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the best way to search an Oracle CLOB column?

Tags:

sql

oracle

I need to search a CLOB column and am looking for the best way to do this, I've seen variants online of using the DBMS_LOB package as well as using something called Oracle Text. Can someone provide a quick example of how to do this?

like image 669
Adam Fyles Avatar asked Aug 16 '10 12:08

Adam Fyles


People also ask

Can we use Substr on CLOB in Oracle?

SUBSTR and REGEXP_SUBSTR work on CLOBs as well.

What does DBMS_LOB Createtemporary do?

n createtemporary: The procedure createtemporary creates a temporary CLOB or BLOB and its corresponding index in the user default temporary tablespace. n instr: Used to return the matching position of the nth occurrence of the pattern in the LOB. n getlength: Used to get the length of specified LOB.

How does CLOB data look like?

The CLOB data type is similar to a BLOB, but includes character encoding, which defines a character set and the way each character is represented. BLOB data, on the other hand, consists of unformatted binary data. Common data types used for storing character data include char, varchar, and text.


2 Answers

Oracle Text indexing is the way go. You can use either CONTEXT or CTXRULE index. CONTEXT can be used on unstructured document where CTXRULE is more helpful on structured documents.

This link will provide more info the index types & syntax.

The most important factor you need to consider is LEXER & STOPLIST.

You can also read the posts on asktom.oracle.com

http://asktom.oracle.com/pls/apex/f?p=100:11:0::::P11_QUESTION_ID:5533095920114

like image 200
Baski Avatar answered Sep 20 '22 03:09

Baski


What is in your CLOB and what are you searching for ?

Oracle Text is good if you are searching for words or phrases (which is probably what you have in a CLOB). Sometimes you'll store something 'strange' in a CLOB, like XML or the return value of a web-service call and that might be a different kettle of fish.

like image 40
Gary Myers Avatar answered Sep 19 '22 03:09

Gary Myers