Home  >  Article  >  Database  >  How to reverse oracle string

How to reverse oracle string

WBOY
WBOYOriginal
2022-06-10 15:40:572727browse

In Oracle, you can use the reverse function to reverse a string. The function of this function is to reversely convert an object. The syntax is "select reverse('String to be reversed') from dual;"; This function is to reverse the encoding of objects stored inside the database. What is stored is not the result of direct encoding, but after some kind of internal conversion.

How to reverse oracle string

The operating environment of this tutorial: Windows 10 system, Oracle version 12c, Dell G3 computer.

How to reverse oracle string

Oracle provides a reverse function that can reversely convert an object.

For example:

How to reverse oracle string

Because this function reverses the encoding of objects stored in the database,

Therefore, for example: numbers, Chinese, etc. Because what is stored is not the directly encoded result. , but is achieved after some internal conversion. Therefore, after the conversion is completed, it may not be the result you want. Example:

SQL> select reverse(123456) ,reverse('×××') from dual;
REVERSE(123456) REVERSE('×××')
--------------- -------------------------
-668706000000 ?秃补衩巳?兄

In this place, an integer and a Chinese content are It has been converted into other content.

Let’s dump and see how Oracle reverses

SQL> select reverse(123456),dump(123456),dump(reverse(123456)) from dual;
REVERSE(123456) DUMP(123456) DUMP(REVERSE(123456))
--------------- ------------------------- -------------------------
-668706000000 Typ=2 Len=4: 195,13,35,57 Typ=2 Len=4: 57,35,13,195

Recommended tutorial: "Oracle Video Tutorial"

The above is the detailed content of How to reverse oracle string. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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