Query Whether the Oracle Database is CDB or Non-CDB
Hello, this is Bing. I can help you rewrite your content in a more SEO-friendly way for a blog post. Here is a possible rewrite:
How to Check If Your Oracle Database Is a CDB or a Non-CDB
Oracle Database 12c introduced the concept of a multitenant architecture, which allows you to create multiple pluggable databases (PDBs) within a single container database (CDB). A CDB can host up to 252 PDBs, which share the same memory and background processes, but have their own data files and schemas. A non-CDB is a traditional Oracle database that does not have any PDBs.
If you want to know whether your Oracle database is a CDB or a non-CDB, you can use a simple SQL query to check the value of the CDB column in the V$DATABASE view. The V$DATABASE view contains information about the current database instance, such as its name, ID, version, and status.
To query the CDB column, you need to connect to the database as a user with the SELECT_CATALOG_ROLE privilege, such as SYS. You can use SQLPlus, a command-line tool, to connect to the database and run the query. Here are the steps to follow:
- Open a terminal window and enter the following command to connect to the database as SYS:
[oracle@orcldb ~]$ sqlplus / as sysdba
- You should see a message like this, indicating that you are connected to the database:
Connected to:
Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production
- Enter the following SQL query to check the value of the CDB column:
SQL> SELECT CDB FROM V$DATABASE;
- The query will return either YES or NO, depending on whether the database is a CDB or a non-CDB. For example, if the database is a CDB, you will see something like this:
CDB
---
YES
If you want to get more information about the containers in your CDB, you can use another SQL query to retrieve the name, ID, and other details of each container from the V$CONTAINERS view. The V$CONTAINERS view contains information about all the containers in the current CDB, including the root container (CDB$ROOT) and the seed container (PDB$SEED).
To query the V$CONTAINERS view, you need to be in the root container, which is the default container when you connect to the database as SYS. You can use the SHOW CON_NAME command to verify the current container name. You can also use the COLUMN command to format the output of the query. Here are the steps to follow:
- Enter the following command to show the current container name:
SQL> SHOW CON_NAME
- You should see something like this, indicating that you are in the root container:
CON_NAME
------------------------------
CDB$ROOT
- Enter the following commands to format the output and query the V$CONTAINERS view:
SQL> COLUMN NAME FORMAT A8
SQL> SELECT NAME, CON_ID, DBID, CON_UID, GUID FROM V$CONTAINERS ORDER BY CON_ID;
- The query will return a list of containers with their name, ID, and other details. For example, you might see something like this:
NAME CON_ID DBID CON_UID GUID
-------- ---------- ---------- ---------- --------------------------------
CDB$ROOT 1 629189539 1 090FA6F89C7572A1E0436797E40AC78D
PDB$SEED 2 1026479912 1026479912 090FAE9C00377591E0436797E40AC138
ORCL 3 5718888687 5718888687 090F7543B8826B8BE0532300A8C0FBA1
Have a nice day! 😊