oracle中“to_char”方法的使用:1、用于日期轉(zhuǎn)換,語(yǔ)法為“to_char(date,’日期格式’);”;2、用于處理數(shù)字,語(yǔ)法為“to_char(number,’格式’);”;3、用于將字段轉(zhuǎn)換為字符串,語(yǔ)法為“to_char(字段)”。
本教程操作環(huán)境:windows10系統(tǒng)、Oracle 11g版、Dell G3電腦。
oracle中to char方法怎么用
1)用作日期轉(zhuǎn)換:
to_char(date,'格式');
示例如下:
select?to_date('2005-01-01?','yyyy-MM-dd')?from?dual; select?to_char(sysdate,'yyyy-MM-dd?HH24:mi:ss')?from?dual;
(2)處理數(shù)字:
to_char(number,'格式');
示例如下:
select?to_char(88877)?from?dual; select?to_char(1234567890,'099999999999999')??from?dual; select?to_char(12345678,'999,999,999,999')??from?dual; select?to_char(123456,'99.999')??from?dual; select?to_char(1234567890,'999,999,999,999.9999')??from?dual;
(3)TO_CHAR 是把xxx轉(zhuǎn)換為字符串,不能指定字符串長(zhǎng)度。
TO_CHAR(xxx) ?例如:TO_CHAR(999) ?得到字符串999
擴(kuò)展知識(shí):
to_char(salary,’$99,99′);
?select?TO_CHAR(123,'$99,999.9')?from?dual;
用于進(jìn)制轉(zhuǎn)換:將10進(jìn)制轉(zhuǎn)換為16進(jìn)制;
select?to_char(4567,'xxxx')?from?dual; select?to_char(123,'xxx')?from?dual;
推薦教程:《Oracle視頻教程》
? 版權(quán)聲明
文章版權(quán)歸作者所有,未經(jīng)允許請(qǐng)勿轉(zhuǎn)載。
THE END
喜歡就支持一下吧
相關(guān)推薦