oracle進位制轉換to_number_to_char_bin_to_num

wisdomone1發表於2010-06-24
SQL> select to_char('10','xxxx') from dual;#十進位制轉換為十六進位制
TO_CHAR('1
----------
    a
SQL> select to_char('1','xxxx') from dual;
TO_CHAR('1
----------
    1
SQL> select to_char('11','xxxx') from dual;
TO_CHAR('1
----------
    b
SQL> select to_number('016f','xxxx') from dual;#十六進位制轉換為十進位制TO_NUMBER('016F','XXXX')
------------------------
                     367
SQL>
SQL>
SQL> select bin_to_num(1,1) from dual;
BIN_TO_NUM(1,1)
---------------
              3
SQL> select bin_to_num(1,1,1,1) from dual;
BIN_TO_NUM(1,1,1,1)
-------------------
                 15
 
 
 
 
SQL> select to_number('016f','xxxx') from dual;#016f為ultraedit第2,3位元組的十六
      進位制數,轉換為十進位制
TO_NUMBER('016F','XXXX')
------------------------
                     367
 
 
#一定要在轉換後的十進位制次前面加上to_number函式,然後再用nls_charset_name
SQL> select nls_charset_name(to_number('367','xxxx')) from dual;
NLS_CHARSET_NAME(TO_NUMBER('367','XXXX'))
--------------------------------------------------------------------------------
UTF8
SQL> select nls_charset_name(to_number('367','xxxx')) from dual;
NLS_CHARSET_NAME(TO_NUMBER('367','XXXX'))
--------------------------------------------------------------------------------
UTF8
SQL> select nls_charset_name(to_number('354','xxxx')) from dual;
NLS_CHARSET_NAME(TO_NUMBER('354','XXXX'))
--------------------------------------------------------------------------------
ZHS16GBK

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

相關文章