How oracle determines whether it contains a string

The first thing that comes to mind is contains. The usage of contains is as follows:

 

[sql]  view plain copy  
 
  1. select * from students where contains(address,  'beijing')  


However, there is a condition for using the contains predicate, that is, the column must be indexed, that is to say, if the address column of the students table in the above statement is not indexed, then an error will be reported.

Fortunately, we have another way, that is to use instr, the usage of instr is as follows:

 

[sql]  view plain copy  
 
  1. select * from students where instr(address, 'beijing') > 0  


In addition, there is a stupid way, that is to use like, everyone should know how to do it here:

 

[sql]  view plain copy  
 
    1. select * from students where address like '%beijing%'  

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325946993&siteId=291194637