Home > Database > Oracle > body text

How to use to_char method in oracle

WBOY
Release: 2022-06-07 17:56:24
Original
23109 people have browsed it

oracle中“to_char”方法的使用:1、用于日期转换,语法为“to_char(date,'日期格式');”;2、用于处理数字,语法为“to_char(number,'格式');”;3、用于将字段转换为字符串,语法为“to_char(字段)”。

How to use to_char method in oracle

本教程操作环境:windows10系统、Oracle 11g版、Dell G3电脑。

oracle中to char方法怎么用

1)用作日期转换:

to_char(date,'格式');
Copy after login

示例如下:

select to_date('2005-01-01 ','yyyy-MM-dd') from dual;
select to_char(sysdate,'yyyy-MM-dd HH24:mi:ss') from dual;
Copy after login

(2)处理数字:

to_char(number,'格式');
Copy after login

示例如下:

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;
Copy after login

(3)TO_CHAR 是把xxx转换为字符串,不能指定字符串长度。

TO_CHAR(xxx) 例如:TO_CHAR(999) 得到字符串999

扩展知识:

to_char(salary,'$99,99');

 select TO_CHAR(123,'$99,999.9') from dual;
Copy after login

用于进制转换:将10进制转换为16进制;

select to_char(4567,'xxxx') from dual;
select to_char(123,'xxx') from dual;
Copy after login

推荐教程:《Oracle视频教程

The above is the detailed content of How to use to_char method in oracle. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!