Syntax
TO_PINYIN('chinese_string','option')
Parameters
option specifies the option. For example, the following table describes the options for the "database" scenario.
| OPTION option | All lowercase | First letter capitalized | All capital letters |
|---|---|---|---|
| First letter | INITIAL (sjk) |
CAP_INITIAL (Sjk) |
ALL_CAP_INITIAL (SJK) |
| Full pinyin | FULL (default mode when no option is specified) (shujuku) |
CAP (ShuJuKu) FIRST_CAP (Shujuku) |
ALL_CAP (SHUJUKU) |
Purpose
This function converts Chinese text to pinyin.
The function accepts a Chinese string as input and returns a string containing the corresponding pinyin.
Examples
Example 1:
Execute the following command to convert a Chinese string to its 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 a Chinese string to its corresponding pinyin string with the first letter capitalized.
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)