《oracle中的trunc函数详解》由会员分享,可在线阅读,更多相关《oracle中的trunc函数详解(2页珍藏版)》请在金锄头文库上搜索。
1、trunc(number)在Oracle/PLSQL中, trunc function returns a number truncated to a certain number of decimal places.trunc function 语法如下:trunc( number, decimal_places )number 要截取的数字.decimal_places 要保留的小数位. 这个参数必须是个整数. 如果此参数缺省,默认保留0位小数应用于: Oracle 8i, Oracle 9i, Oracle 10g, Oracle 11g 例如For example:trunc(125.
2、815)would return 125trunc(125.815, 0)would return 125trunc(125.815, 1)would return 125.8trunc(125.815, 2)would return 125.81trunc(125.81, 3)would return 125.81trunc(-125.815, 2)would return -125.81trunc(125.815, -1)would return 120trunc(125.815, -2)would return 100trunc(125.81, -3)would return 0如果decimal_places 大于number 本身的小数位数,返回原数字不会加0.如:trunc(125.81,3) would return 125.81;如果decimal_places 为负数,那么将指定的位数