mysql和oracle字串編碼轉換函式,字串轉位元組函式例子

e71hao發表於2015-12-09
1.mysql [localhost] {msandbox} > select hex(convert('寰堝睂' using gbk));
+-------------------------------------+
| hex(convert('寰堝睂' using gbk))    |
+-------------------------------------+
| E5BE88E5B18C                        |
+-------------------------------------+
1 row in set (0.01 sec)
mysql [localhost] {msandbox} ((none)) > select convert(0xE5BE88E5B18C using utf8);
+------------------------------------+
| convert(0xE5BE88E5B18C using utf8) |
+------------------------------------+
| 很屌                               |
+------------------------------------+
1 row in set (0.00 sec)


2.
SQL> select convert('寰堝睂','AL32UTF8') from dual;
 
CONVERT('寰堝睂','AL32UTF8'
------------------------------
寰堝睂
SQL> select convert('寰堝睂','ZHS16GBK') from dual;
 
CONVERT('寰堝睂','ZHS16GBK'
------------------------------
很屌
SQL> select convert('很屌','AL32UTF8') from dual;
 
CONVERT('很屌','AL32UTF8')
----------------------------
很屌
SQL> select  nlssort('寰堝睂') from dual;
 
NLSSORT('寰堝睂')
--------------------
E5AFB0E5A09DE79D8200
SQL> select  nlssort('很屌') from dual;
 
NLSSORT('很屌')
-----------------
E5BE88E5B18C00

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/30393770/viewspace-1869124/,如需轉載,請註明出處,否則將追究法律責任。

相關文章