Database SQL Language Reference
ContentsOpens a new window
Opens a new window
Page 75 of 554

Single-Row Functions

Single-row functions return a single result row for every row of a queried table or view. These functions can appear in select lists, WHERE clauses, START WITH and CONNECT BY clauses, and HAVING clauses.

Numeric Functions

Numeric functions accept numeric input and return numeric values. Most numeric functions return NUMBER values that are accurate to 38 decimal digits. The transcendental functions COS, COSH, EXP, LN, LOG, SIN, SINH, SQRT, TAN, and TANH are accurate to 36 decimal digits. The transcendental functions ACOS, ASIN, ATAN, and ATAN2 are accurate to 30 decimal digits. The numeric functions are:


ABSOpens a new window
ACOSOpens a new window
ASINOpens a new window
ATANOpens a new window
ATAN2Opens a new window
BITANDOpens a new window
CEILOpens a new window
COSOpens a new window
COSHOpens a new window
EXPOpens a new window
FLOOROpens a new window
LNOpens a new window
LOGOpens a new window
MODOpens a new window
NANVLOpens a new window
POWEROpens a new window
REMAINDEROpens a new window
ROUND (number)Opens a new window
SIGNOpens a new window
SINOpens a new window
SINHOpens a new window
SQRTOpens a new window
TANOpens a new window
TANHOpens a new window
TRUNC (number)Opens a new window
WIDTH_BUCKETOpens a new window

Character Functions Returning Character Values

Character functions that return character values return values of the following data types unless otherwise documented:

  • If the input argument is CHAR or VARCHAR2, then the value returned is VARCHAR2.

  • If the input argument is NCHAR or NVARCHAR2, then the value returned is NVARCHAR2.

The length of the value returned by the function is limited by the maximum length of the data type returned.

  • For functions that return CHAR or VARCHAR2, if the length of the return value exceeds the limit, then Oracle Database truncates it and returns the result without an error message.

  • For functions that return CLOB values, if the length of the return values exceeds the limit, then Oracle raises an error and returns no data.

The character functions that return character values are:


CHROpens a new window
CONCATOpens a new window
INITCAPOpens a new window
LOWEROpens a new window
LPADOpens a new window
LTRIMOpens a new window
NCHROpens a new window
NLS_INITCAPOpens a new window
NLS_LOWEROpens a new window
NLS_UPPEROpens a new window
NLSSORTOpens a new window
REGEXP_REPLACEOpens a new window
REGEXP_SUBSTROpens a new window
REPLACEOpens a new window
RPADOpens a new window
RTRIMOpens a new window
SOUNDEXOpens a new window
SUBSTROpens a new window
TRANSLATEOpens a new window
TRANSLATE ... USINGOpens a new window
TRIMOpens a new window
UPPEROpens a new window

Character Functions Returning Number Values

Character functions that return number values can take as their argument any character data type. The character functions that return number values are:


ASCIIOpens a new window
INSTROpens a new window
LENGTHOpens a new window
REGEXP_COUNTOpens a new window
REGEXP_INSTROpens a new window

Character Set Functions

The character set functions return information about the character set. The character set functions are:


NLS_CHARSET_DECL_LENOpens a new window
NLS_CHARSET_IDOpens a new window
NLS_CHARSET_NAMEOpens a new window

Datetime Functions

Datetime functions operate on date (DATE), timestamp (TIMESTAMP, TIMESTAMP WITH TIME ZONE, and TIMESTAMP WITH LOCAL TIME ZONE), and interval (INTERVAL DAY TO SECOND, INTERVAL YEAR TO MONTH) values.

Some of the datetime functions were designed for the Oracle DATE data type (ADD_MONTHS, CURRENT_DATE, LAST_DAY, NEW_TIME, and NEXT_DAY). If you provide a timestamp value as their argument, then Oracle Database internally converts the input type to a DATE value and returns a DATE value. The exceptions are the MONTHS_BETWEEN function, which returns a number, and the ROUND and TRUNC functions, which do not accept timestamp or interval values at all.

The remaining datetime functions were designed to accept any of the three types of data (date, timestamp, and interval) and to return a value of one of these types.

All of the datetime functions that return current system datetime information, such as SYSDATE, SYSTIMESTAMP, CURRENT_TIMESTAMP, and so forth, are evaluated once for each SQL statement, regardless how many times they are referenced in that statement.

The datetime functions are:


ADD_MONTHSOpens a new window
CURRENT_DATEOpens a new window
CURRENT_TIMESTAMPOpens a new window
DBTIMEZONEOpens a new window
EXTRACT (datetime)Opens a new window
FROM_TZOpens a new window
LAST_DAYOpens a new window
LOCALTIMESTAMPOpens a new window
MONTHS_BETWEENOpens a new window
NEW_TIMEOpens a new window
NEXT_DAYOpens a new window
NUMTODSINTERVALOpens a new window
NUMTOYMINTERVALOpens a new window
ORA_DST_AFFECTEDOpens a new window
ORA_DST_CONVERTOpens a new window
ORA_DST_ERROROpens a new window
ROUND (date)Opens a new window
SESSIONTIMEZONEOpens a new window
SYS_EXTRACT_UTCOpens a new window
SYSDATEOpens a new window
SYSTIMESTAMPOpens a new window
TO_CHAR (datetime)Opens a new window
TO_DSINTERVALOpens a new window
TO_TIMESTAMPOpens a new window
TO_TIMESTAMP_TZOpens a new window
TO_YMINTERVALOpens a new window
TRUNC (date)Opens a new window
TZ_OFFSETOpens a new window

General Comparison Functions

The general comparison functions determine the greatest and or least value from a set of values. The general comparison functions are:


GREATESTOpens a new window
LEASTOpens a new window

Conversion Functions

Conversion functions convert a value from one data type to another. Generally, the form of the function names follows the convention datatype TO datatype. The first data type is the input data type. The second data type is the output data type. The SQL conversion functions are:


ASCIISTROpens a new window
BIN_TO_NUMOpens a new window
CASTOpens a new window
CHARTOROWIDOpens a new window
COMPOSEOpens a new window
CONVERTOpens a new window
DECOMPOSEOpens a new window
HEXTORAWOpens a new window
NUMTODSINTERVALOpens a new window
NUMTOYMINTERVALOpens a new window
RAWTOHEXOpens a new window
RAWTONHEXOpens a new window
ROWIDTOCHAROpens a new window
ROWIDTONCHAROpens a new window
SCN_TO_TIMESTAMPOpens a new window
TIMESTAMP_TO_SCNOpens a new window
TO_BINARY_DOUBLEOpens a new window
TO_BINARY_FLOATOpens a new window
TO_BLOBOpens a new window
TO_CHAR (character)Opens a new window
TO_CHAR (datetime)Opens a new window
TO_CHAR (number)Opens a new window
TO_CLOBOpens a new window
TO_DATEOpens a new window
TO_DSINTERVALOpens a new window
TO_LOBOpens a new window
TO_MULTI_BYTEOpens a new window
TO_NCHAR (character)Opens a new window
TO_NCHAR (datetime)Opens a new window
TO_NCHAR (number)Opens a new window
TO_NCLOBOpens a new window
TO_NUMBEROpens a new window
TO_SINGLE_BYTEOpens a new window
TO_TIMESTAMPOpens a new window
TO_TIMESTAMP_TZOpens a new window
TO_YMINTERVALOpens a new window
TREATOpens a new window
UNISTROpens a new window

Large Object Functions

The large object functions operate on LOBs. The large object functions are:


BFILENAMEOpens a new window
EMPTY_BLOB, EMPTY_CLOBOpens a new window

Collection Functions

The collection functions operate on nested tables and varrays. The SQL collection functions are:


CARDINALITYOpens a new window
COLLECTOpens a new window
POWERMULTISETOpens a new window
POWERMULTISET_BY_CARDINALITYOpens a new window
SETOpens a new window

Hierarchical Functions

Hierarchical functions applies hierarchical path information to a result set. The hierarchical function is:


SYS_CONNECT_BY_PATHOpens a new window

Data Mining Functions

The data mining functions use Oracle Data Mining to score data. The functions can apply a mining model schema object to the data, or they can dynamically mine the data by executing an analytic clause.

The data mining functions are:


CLUSTER_DETAILSOpens a new window
CLUSTER_DISTANCEOpens a new window
CLUSTER_IDOpens a new window
CLUSTER_PROBABILITYOpens a new window
CLUSTER_SETOpens a new window
FEATURE_DETAILSOpens a new window
FEATURE_IDOpens a new window
FEATURE_SETOpens a new window
FEATURE_VALUEOpens a new window
PREDICTIONOpens a new window
PREDICTION_BOUNDSOpens a new window
PREDICTION_COSTOpens a new window
PREDICTION_DETAILSOpens a new window
PREDICTION_PROBABILITYOpens a new window
PREDICTION_SETOpens a new window

See Also:

XML Functions

The XML functions operate on or return XML documents or fragments. These functions use arguments that are not defined as part of the ANSI/ISO/IEC SQL Standard but are defined as part of the World Wide Web Consortium (W3C) standards. The processing and operations that the functions perform are defined by the relevant W3C standards. The table below provides a link to the appropriate section of the W3C standard for the rules and guidelines that apply to each of these XML-related arguments. A SQL statement that uses one of these XML functions, where any of the arguments does not conform to the relevant W3C syntax, will result in an error. Of special note is the fact that not every character that is allowed in the value of a database column is considered legal in XML.

For more information about selecting and querying XML data using these functions, including information on formatting output, refer to Oracle XML DB Developer's GuideOpens a new window.

The SQL XML functions are:


APPENDCHILDXMLOpens a new window
DELETEXMLOpens a new window
DEPTHOpens a new window
EXISTSNODEOpens a new window
EXTRACT (XML)Opens a new window
EXTRACTVALUEOpens a new window
INSERTCHILDXMLOpens a new window
INSERTCHILDXMLAFTEROpens a new window
INSERTCHILDXMLBEFOREOpens a new window
INSERTXMLAFTEROpens a new window
INSERTXMLBEFOREOpens a new window
PATHOpens a new window
SYS_DBURIGENOpens a new window
SYS_XMLAGGOpens a new window
SYS_XMLGENOpens a new window
UPDATEXMLOpens a new window
XMLAGGOpens a new window
XMLCASTOpens a new window
XMLCDATAOpens a new window
XMLCOLATTVALOpens a new window
XMLCOMMENTOpens a new window
XMLCONCATOpens a new window
XMLDIFFOpens a new window
XMLELEMENTOpens a new window
XMLEXISTSOpens a new window
XMLFORESTOpens a new window
XMLISVALIDOpens a new window
XMLPARSEOpens a new window
XMLPATCHOpens a new window
XMLPIOpens a new window
XMLQUERYOpens a new window
XMLROOTOpens a new window
XMLSEQUENCEOpens a new window
XMLSERIALIZEOpens a new window
XMLTABLEOpens a new window
XMLTRANSFORMOpens a new window

JSON Functions

The JavaScript Object Notation (JSON) functions return values from JSON data. The JSON functions are:


JSON_QUERYOpens a new window
JSON_TABLEOpens a new window
JSON_VALUEOpens a new window

Encoding and Decoding Functions

The encoding and decoding functions let you inspect and decode data in the database. The encoding and decoding functions are:


DECODEOpens a new window
DUMPOpens a new window
ORA_HASHOpens a new window
STANDARD_HASHOpens a new window
VSIZEOpens a new window

NULL-Related Functions

The NULL-related functions facilitate null handling. The NULL-related functions are:


COALESCEOpens a new window
LNNVLOpens a new window
NANVLOpens a new window
NULLIFOpens a new window
NVLOpens a new window
NVL2Opens a new window

Environment and Identifier Functions

The environment and identifier functions provide information about the instance and session. The environment and identifier functions are:


CON_DBID_TO_IDOpens a new window
CON_GUID_TO_IDOpens a new window
CON_NAME_TO_IDOpens a new window
CON_UID_TO_IDOpens a new window
ORA_INVOKING_USEROpens a new window
ORA_INVOKING_USERIDOpens a new window
SYS_CONTEXTOpens a new window
SYS_GUIDOpens a new window
SYS_TYPEIDOpens a new window
UIDOpens a new window
USEROpens a new window
USERENVOpens a new window