Get the App
SLTechnology News&Howtos  ›  Database  › 

The usage of Oracle NVL function

Shulou Source: shulou.com Published: 2022-06-01 13:47:11 11月14日 Update

Today, I studied the process in the database and found that NVL is used. My memory is not good. I used it before and forgot it for a long time. So I went to check the official explanation:

http://docs.oracle.com/cd/E11882_01/server.112/e41084/functions119.htm#i91798

NVL belongs to character conversion output is also character type.

The expression is NVL(expr1,expr2)

Its purpose is to convert "empty" characters into "non-empty" characters, when expr1 is empty, output expr2, otherwise output expr1.

Expr1 and expr2 can be of any data type. If the data types of the two are inconsistent, type conversion will be performed.

The principles of its transformation follow:

If expr1 is a character type, convert expr2 to expr1's type before comparing and return the character set as varchar2.

2. If expr1 is a numeric type, Oracle itself will convert the data type to a high-priority data type according to the highest priority judgment.

and ultimately returns data of that type.

Examples:

SELECT NVL(MAX(ID), 0) FROM WAYBILL;

This means that 0 is returned when the largest ID in the WAYBILL table is empty.

Tags: Type character data output function maximum highest consistent bad no priority principle original text character set official that is meaning numerical value database time Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Tech Info MariaDB Redmi Linux Apple