Home > Database > Oracle > body text

What function is used to represent a certain character in Oracle?

下次还敢
Release: 2024-05-08 19:06:20
Original
1128 people have browsed it

Function that contains a certain character in Oracle

In Oracle, you can use the INSTR function to determine whether a string contains a certain character.

Syntax

<code>INSTR(string, search_string, start_position, occurrence)</code>
Copy after login

Parameters

  • string: The string to search for.
  • search_string: The character or substring to be found.
  • start_position (optional): From which position in the string to start searching (counting from 1).
  • occurrence (optional): The number of occurrences to find (counting from 1).

Return value

If search_string is found, return its first occurrence in string index position. If not found, returns 0.

Example

Find whether the character "r" exists in the string "Oracle":

<code>SELECT INSTR('Oracle', 'r');</code>
Copy after login

Result:

<code>3</code>
Copy after login

This Indicates that the character "r" is at position 3 (counting from 1) in the string "Oracle".

Find the third occurrence of the character "d" in the string "Database":

<code>SELECT INSTR('Database', 'd', 1, 3);</code>
Copy after login

Result:

<code>7</code>
Copy after login

This means that the character "d" appears in the string "Database" The third occurrence of " is in position 7 (counting from 1).

Note

  • start_position parameter can only be used when the second parameter is a substring.
  • occurrence Parameters can only be used when the first parameter is a string.
  • If start_position or occurrence is negative or zero, treat it as 1.

The above is the detailed content of What function is used to represent a certain character in Oracle?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template