Oracle CONTAINS Function Guide

The contains function in Oracle is used to determine if a specified string is contained in a text column. Its basic syntax is as follows:

CONTAINS(column_name, 'search_string') > 0

In this case, column_name is the name of the text column to search, and search_string is the string to look for. If the specified string is found in the text column, the CONTAINS function will return a value greater than 0, otherwise it will return 0.

For example, the following sample query will return records containing the string ‘apple’:

SELECT * FROM table_name
WHERE CONTAINS(column_name, 'apple') > 0;

It should be noted that the CONTAINS function can only be used on columns with full-text indexes. Before using it, make sure that a full-text index has been created on the column.

bannerAds