http://docs.oracle.com/cd/E11882_01/server.112/e41084/functions069.htm#i77473
http://docs.oracle.com/cd/E11882_01/server.112/e41084/functions087.htm#i77700
这两个函数是是一对相反的函数,语法分别为:
他们都通过第一个expr的字符类型确定返回值的数据类型。如果第一个表达式是数值型的,则根据数值优先的原则,函数会隐式的将后续的表达是转换为数值类型。
范例:
SQL> select least('china','england','american','russia') country from dual;
COUNTRY
------------------------
american
SQL> select greatest('china','england','american','russia') country from dual;
COUNTRY
------------------
russia
SQL> select least(1,'england','russia') country from dual;
select least(1,'england','russia') country from dual
*
ERROR at line 1:
ORA-01722: invalid number
报错出现,说明当我指定数值类型时,后续的表达式都被转化为数值型了
SQL> select least(1,3.14159,0.1415926) country from dual;
COUNTRY
----------
.1415926
SQL> select greatest(1,3.14159,0.1415926) country from dual;
COUNTRY
----------
3.14159
SQL> select least('china','england',2,1) country from dual;
COU
---
1
这里可以看到这里后续的数值被转化为字符类型了。