首页 > 代码库 > ORACLE函数之单行数字函数

ORACLE函数之单行数字函数



1、           ABS(X)

返回X的绝对值

SQL>SELECT ABS(-1) A,ABS(1) B,ABS(0) C FROM DUAL;

        A         B          C

-------------------- ----------

        1         1          0

2、          ACOS(X)

返回X的反余弦值

SQL>SELECT ACOS(0) A,ACOS(0.5) B,ACOS(1) C FROM DUAL;

        A         B          C

-------------------- ----------

1.570796321.04719755         0

 

3、      ASIN(X)

返回X的反正弦值

SQL>SELECT ASIN(0) A,ASIN(0.5) B,ASIN(1) C FROM DUAL;

        A         B          C

-------------------- ----------

        0 0.52359877 1.57079632

4、          ATAN(X)

返回X的反正切值

 

SQL>SELECT ATAN(0) A,ATAN(0.5) B,ATAN(1) C FROM DUAL;

        A         B          C

-------------------- ----------

        0 0.46364760 0.78539816

 

5、        ATAN2(X,Y)

返回数字X除以Y的反正切值,Y不能为0

SQL>SELECT ATAN2(3,4) A FROM DUAL;

        A

----------

0.64350110

6、         CEIL(X)

返回大于等于X的最小整数

SQL>SELECT CEIL(0) A,CEIL(-0.5) B,CEIL(0.5) C,CEIL(5) D,CEIL(-5) E FROM DUAL;

        A         B         C         D         E

-------------------- ---------- ---------- ----------

        0         0          1         5         -5

 

7、           COS(X)

说明:返回X的余弦值

举例:

SQL>SELECT COS(0) A,COS(45) B, COS(90) C FROM DUAL;

        A         B          C

-------------------- ----------

        1 0.52532198 -0.4480736

8、           COSH(X)

说明:返回X的双余弦值

举例:

SQL>SELECT COSH(0) A,COSH(45) B,COSH(90) C FROM DUAL;

        A         B          C

-------------------- ----------

        1 1.74671355 6.10201647

9、           EXP(X)

说明:返回eX次幂

举例:

SQL>SELECT EXP(0) A,EXP(1) B,EXP(10) C FROM DUAL;

        A         B         C

-------------------- ----------

        1 2.71828182 22026.4657

10、      FLOOR(X)

说明:返回小于等于X的最大整数

举例:

SQL> SELECT FLOOR(0) A,FLOOR(-1.5)B,FLOOR(-1) C,FLOOR(1.5) D,FLOOR(2) E FROM DUAL;

        A         B         C          D         E

---------- ---------- -------------------- ----------

        0        -2        -1          1         2

11、       LN(X)

说明:返回X的自然对数,X不能为0

举例:

SQL>SELECT LN(1) A,LN(45) B FROM DUAL;

        A         B

--------------------

        0 3.80666248

12、      LOG(Y,X)

说明:返回以Y为底X的对数,Y不能为0

举例:

SQL>SELECT LOG(10,5) A,LOG(10,20) B,LOG(10,10) C FROM DUAL;

        A         B          C

-------------------- ----------

0.698970001.30102999         1

13、      MOD(Y,X)

说明:返回Y除以X以后的余数,如果X0,则返回Y

举例:

SQL>SELECT MOD(10,10) A,MOD(10,5) B,MOD(10,0) C,MOD(10,20) D FROM DUAL;

        A         B          C         D

-------------------- ---------- ----------

        0         0         10        10

14、       POWER(Y,X)

说明:返回以Y为底的X次幂。YX可以为任意数字,但如果Y为负数,则X必须为正数

举例:

SQL>SELECT POWER(2,3) A,POWER(-2,3) B,POWER(2,-3) C FROM DUAL;

        A         B          C

-------------------- ----------

        8        -8     0.125

15、      ROUND(X[,Y])

说明:执行四舍五入运算。如果省略Y,则四舍五入到整数位;如果Y为负数,则到小数点前Y位;如果Y为正数,则到小数点后Y位。

举例:

SQL>SELECT ROUND(123.4567) A,ROUND(123.4567,3) B,ROUND(123.4567,-1) C FROM DUAL;

        A         B          C

-------------------- ----------

      123   123.457       120

16、       SIGN(X)

说明:检测X的正负。如果小于0,则返回-1;如果X等于0,则返回0;如果X大于0,则返回1

举例:

SQL>SELECT SIGN(-100) A,SIGN(0) B,SIGN(100) C FROM DUAL;

        A         B          C

-------------------- ----------

       -1         0          1

17、      SIN(X)

说明:返回X的正弦值

举例:

SQL>SELECT SIN(0) A,SIN(45) B,SIN(90) C FROM DUAL;

        A         B          C

-------------------- ----------

        0 0.85090352 0.89399666

18、      SINH(X)

说明:返回X的双正弦值

举例:

SQL>SELECT SINH(0) A,SINH(45) B,SINH(90) C FROM DUAL;

        A         B          C

-------------------- ----------

        0 1.74671355 6.10201647

19、      SQRT(X)

说明:返回X的平方根,X必须大于等于0

举例:

SQL>SELECT SQRT(0) A,SQRT(1) B,SQRT(2) C FROM DUAL;

        A         B          C

-------------------- ----------

        0         1 1.41421356

20、      TAN(X)

说明:返回X的正切值

举例:

SQL>SELECT TAN(0) A,TAN(45) B,TAN(90) C FROM DUAL;

        A         B          C

-------------------- ----------

        0 1.61977519 -1.9952004

21、       TANH(X)

说明:返回X的双正切值

举例:

SQL>SELECT TANH(0) A,TANH(45) B,TANH(90) C FROM DUAL;

        A         B          C

-------------------- ----------

        0         1          1

22、      TRUNC(X[,Y])

说明:执行截取数字。如果省略Y,则将X的小数部分截取;如果Y是负数,则截取到小数点前Y位;如果Y为正数,则截取到小数点后Y

举例:

SQL>SELECT TRUNC(123.4567) A,TRUNC(123.4567,-2) B,TRUNC(123.4567,2) C FROM DUAL;

        A         B          C

-------------------- ----------

      123       100    123.45