Syntax
TO_PINYIN('chinese_string','option')
Parameters
option indicates an optional parameter, and we'll provide you with the parameter names and output results based on the example of "database".
| OPTION | all lowercase | capitalize each word | all uppercase |
|---|---|---|---|
| INITIAL (sjk) |
CAP_INITIAL (Sjk) |
ALL_CAP_INITIAL (SJK) |
|
| Full Pinyin (default mode when unspecified) (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 that contains the corresponding pinyin.
Examples
Example 1:
Run the following command to convert the Chinese string to the corresponding pinyin string.
SELECT TO_PINYIN('database') FROM DUAL;
The returned result is as follows:
+------------------------+
| TO_PINYIN('DATABASE') |
+------------------------+
| shùjùkù |
+------------------------+
1 row in set
Example 2:
Run the following command to convert the Chinese string to a corresponding pinyin string with the first letter capitalized.
SELECT TO_PINYIN('database','CAP') FROM DUAL;
The returned results are as follows:
+------------------------------+
| TO_PINYIN('Database','CAP') |
+------------------------------+
| ShùJùKù |
+------------------------------+
1 row in set (0.000 sec)