CONVERT
功能描述
将字符串从一个语言字符集转换为另一个字符集。
语法格式
CONVERT(expr1, expr2[, expr3])
参数说明
- expr1:源字符串
- expr2:目的字符集
- expr3:源字符集
函数返回类型
CHAR类型字符串
示例
sql
SQL> SHOW DB_INFO
DB_NAME | DB_ID | DB_OWNER | DB_CHARSET | DB_TIMEZ |
------------------------------------------------------------------------------
SYSTEM| 1 | SYS| UTF8.UTF8_GENERAL_CI| GMT+08:00|
SQL> SELECT CONVERT('test_convert','GBK');
EXPR1 |
------------------------------------------------------------------------------
test_convert|
Use time:0 ms.
SQL> SELECT LENGTHB(CONVERT('我爱中国','GBK','UTF8'));
EXPR1 |
------------------------------------------------------------------------------
8 |
SQL> CREATE DATABASE db_convert CHARACTER SET 'GBK' TIME ZONE 'GMT+08:00';
SQL> USE db_convert
SQL> SELECT CONVERT('test_convert','UTF8');
EXPR1 |
------------------------------------------------------------------------------
test_convert|
SQL> SELECT LENGTHB(CONVERT('我爱中国','UTF8','GBK'));
EXPR1 |
------------------------------------------------------------------------------
12 |