---
title: "Oracle中round() 函数与trunc()函数的比较 "
author: "luweifeng1983"
date: "2012-11-29T14:32:41Z"
tags: []
categories: ["数据库"]
slug: "oracle-round-trunc"
draft: false
lastmod: "2012-11-29T14:32:41Z"
id: 1738264
url: "https://quicker.iteye.com/blog/1738264"
---

转：[http://blog.sina.com.cn/s/blog\_3f59116c0100rf3u.html](http://blog.sina.com.cn/s/blog_3f59116c0100rf3u.html)

round(x\[,y])  
【功能】返回四舍五入后的值  
【参数】x,y，数字型表达式,如果y不为整数则截取y整数部分，如果y&gt;0则四舍五入为y位小数，如果y小于0则四舍五入到小数点向左第y位。  
【返回】数字  
【示例】 select round(5555.6666,2.1),round(5555.6666,-2.6),round(5555.6666) from dual;  
返回： 5555.67 , 5600 , 5556  
【相近】trunc(x\[,y]) 返回截取后的值，用法同round(x\[,y]),只是不四舍五入

trunc(x\[,y])  
【功能】返回x按精度y截取后的值  
【参数】x,y，数字型表达式,如果y不为整数则截取y整数部分，如果y&gt;0则截取到y位小数，如果y小于0则截取到小数点向左第y位，小数前其它数据用0表示。  
【返回】数字  
【示例】 select trunc(5555.66666,2.1),trunc(5555.66666,-2.6),trunc(5555.033333) from dual;  
返回：5555.66 5500 5555  
【相近】round(x\[,y]) 返回截取后的值，用法同trunc(x\[,y]),只是要做四舍五入