Syntax
TO_PINYIN('chinese_string','option')
Parameters
option indicates an option, and we'll take "database" as an example to explain the option names and output results based on different scenarios.
| OPTION | all lowercase | capitalized | all uppercase |
|---|---|---|---|
| INITIAL (sjk) |
CAP_INITIAL (Sjk) |
ALL_CAP_INITIAL (SJK) |
|
| Full | Full (default when not specified) (shujuku) |
Cap (ShuJuKu) First_Cap (Shujuku) |
All_Cap (SHUJUKU) |
Purpose
This function is used to convert 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 a corresponding pinyin string.
SELECT TO_PINYIN('database') FROM DUAL;
The return result is as follows:
+------------------------+
| TO_PINYIN('Database') |
+------------------------+
| shùjùkù |
+------------------------+
1 row in set
Example 2:
Run the following command to convert the Chinese strings to the corresponding pinyin strings and capitalize the first letter.
SELECT TO_PINYIN('Database','CAP') FROM DUAL;
The result is as follows:
+------------------------------+
| TO_PINYIN('Database','CAP') |
+------------------------------+
| ShùJùKù |
+------------------------------+
1 row in set (0.000 sec)