Oracle TO_CHAR(character) Function

Oracle TO_CHAR(character) is a built-in function that converts NCHAR, NVARCHAR2, CLOB, or NCLOB data to the database character set.

Oracle TO_CHAR(character) Syntax

Here is the syntax for the Oracle TO_CHAR(character) function:

TO_CHAR(nchar | clob | nclob)

Parameters

nchar | clob | nclob

Required.

Return Value

The Oracle TO_CHAR(character) function returns a value of type VARCHAR2 that converts the given NCHAR, NVARCHAR2, CLOB, or NCLOB data to the database character set.

When you use this function to convert character LOBs to the database character set, if the LOB value to be converted is larger than the target type, the database will return an error.

Oracle TO_CHAR(character) Example

The following example converts a few simple strings to character data:

SELECT
    TO_CHAR('0111'),
    TO_CHAR('ABCD'),
    TO_CHAR('A1B2')
FROM dual;

输出:

TO_CHAR('0111')    TO_CHAR('ABCD')    TO_CHAR('A1B2')
__________________ __________________ __________________
0111               ABCD               A1B2

Conclusion

Oracle TO_CHAR(character) is a built-in function that converts NCHAR, NVARCHAR2, CLOB, or NCLOB data to the database character set.