Syntax
TO_PINYIN('chinese_string','option')
Parameters
option indicates an optional parameter. This example uses the database as an example to introduce the parameter name and output result in different scenarios.
| OPTION option | All lowercase | First letter capitalized | All capital letters |
|---|---|---|---|
| Initial letter | INITIAL (sjk) |
CAP_INITIAL (Sjk) |
ALL_CAP_INITIAL (SJK) |
| Full pinyin | FULL (default mode when not specified) (shujuku) |
CAP (ShuJuKu) FIRST_CAP (Shujuku) |
ALL_CAP (SHUJUKU) |
Purpose
This function converts Chinese text to pinyin.
It accepts a Chinese string as input and returns a string containing the corresponding pinyin.
Examples
Example 1:
Execute the following command to convert the Chinese string to the corresponding pinyin string.
SELECT TO_PINYIN('database') FROM DUAL;
The return result is as follows:
+------------------------+
| TO_PINYIN('database') |
+------------------------+
| shujuku |
+------------------------+
1 row in set
Example 2:
Execute the following command to convert the Chinese string to the corresponding pinyin string and capitalize the initial letter.
SELECT TO_PINYIN('database','CAP') FROM DUAL;
The return result is as follows:
+------------------------------+
| TO_PINYIN('database','CAP') |
+------------------------------+
| ShuJuKu |
+------------------------------+
1 row in set (0.000 sec)