Home > Database > Oracle > How to use split() function in oracle

How to use split() function in oracle

下次还敢
Release: 2024-05-07 13:06:16
Original
1456 people have browsed it

The SPLIT() function splits a string into an array by the specified delimiter, returning a string array where each element is a delimiter-separated part of the original string. Usage includes: splitting a comma-separated list of values ​​into an array, extracting filenames from paths, and splitting email addresses into usernames and domains.

How to use split() function in oracle

SPLIT() function in Oracle

The SPLIT() function is used to separate strings by specified symbols into arrays. The syntax is as follows:

<code>SPLIT(string, delimiter)</code>
Copy after login

Parameters:

  • string: The string that needs to be split
  • delimiter: The delimiter used to split the string

Return value:

Returns an array of strings in which each element is the delimiter-delimited portion of the original string.

Usage:

The SPLIT() function can be used to solve various string processing tasks, for example:

  • Comma separated list of values ​​split into array:

    <code>SELECT SPLIT('name1,name2,name3', ',') FROM dual;</code>
    Copy after login
  • Extract filename from path:

    <code>SELECT SPLIT('path/to/filename.ext', '/')[-1] FROM dual;</code>
    Copy after login
  • Split email address into Username and Domain:

    <code>SELECT SPLIT('username@domain.com', '@')[1] FROM dual;</code>
    Copy after login

Notes:

  • The delimiter can be a single character or a string.
  • If no delimiter exists in the original string, an array containing a single element is returned, which is the original string.
  • If the delimiter is NULL, split the string into an array with one element per character.

The above is the detailed content of How to use split() function 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