---
title: "关于to_number和to_char函数"
author: "bepatient"
date: "2011-02-06T20:24:29Z"
tags: []
categories: ["数据库"]
slug: "to-number-to-char"
draft: false
lastmod: "2011-02-06T20:24:29Z"
id: 901375
url: "https://bepatient.iteye.com/blog/901375"
---

to\_number是将字符串按照指定的格式专为数字，相反，to\_char是将数字转换为指定格式的字符串。

```
select to_char(1/7,'999,990.99') from dual;--正常

select to_number('19.43453','99999999.99') from dual;--报错，无效字符
select to_number('0.43453','99999990.99') from dual;--报错，无效字符
select to_number('19.43453','99999999.99999999') from dual;--正常

select round(1/7,4) from dual;
```

 oracle order by number/char 数字 

 如果是字符串则不会按顺序