Oracle CON_DBID_TO_ID() Function

Oracle CON_DBID_TO_ID() is a built-in function that returns the container ID based on the container DBID.

Oracle CON_DBID_TO_ID() Syntax

Here is the syntax for the Oracle CON_DBID_TO_ID() function:

CON_DBID_TO_ID(container_dbid)

Parameters

container_dbid

Required. The container DBID. It is a NUMBER value or any value that can be implicitly converted to NUMBER.

Return Value

The Oracle CON_DBID_TO_ID() function returns the container ID, which is a NUMBER value.

If any argument is NULL, CON_DBID_TO_ID() returns NULL.

Oracle CON_DBID_TO_ID() Examples

Here are some examples that demonstrate how to use the Oracle CON_DBID_TO_ID() function.

Basic Usage

You can query all container DBIDs and container IDs from the V$CONTAINERS view, as shown in the following statement:

SELECT
    CON_ID, DBID
FROM v$containers;

Output:

   CON_ID          DBID
_________ _____________
        1    3009309224
        2    2715784909
        3    1348437368

If you need to get the container ID corresponding to container DBID 1348437368, use the CON_DBID_TO_ID() function:

SELECT
    CON_DBID_TO_ID(1348437368)
FROM dual;

Output:

   CON_DBID_TO_ID(1348437368)
_____________________________
                            3

NULL Parameter

If any argument is NULL, CON_DBID_TO_ID() returns NULL.

SET NULL 'NULL';
SELECT
    CON_DBID_TO_ID(NULL)
FROM dual;

Output:

   CON_DBID_TO_ID(NULL)
_______________________
                   NULL

In this example, we use the SET NULL 'NULL'; statement to display the NULL value as the string 'NULL'.

Conclusion

Oracle CON_DBID_TO_ID() is a built-in function that returns the container ID based on the container DBID.