一个Oracle数据库可以有多个DBID吗?

2024-01-03 01:47:06

一个新建的数据库,我在分析 dba_hist_sql_plan 表时,发现其中有2个DBID。

select distinct dbid from dba_hist_sql_plan;

      DBID
----------
1899454952
1467201108

而且两个DBID的记录都很多:

SQL> select count(*) from dba_hist_sql_plan where dbid = 1467201108;

  COUNT(*)
----------
     13478

SQL> select count(*) from dba_hist_sql_plan where dbid = 1899454952;

  COUNT(*)
----------
     16760

实际上,在多租户数据库中,根容器和每一个可插拔数据库都有自己的DBID,这个通过AWR和RMAN都很容易看到。以AWR为例:

SQL> @$ORACLE_HOME/rdbms/admin/awrrpt.sql

Specify the Report Type
~~~~~~~~~~~~~~~~~~~~~~~
AWR reports can be generated in the following formats.  Please enter the
name of the format at the prompt.  Default value is 'html'.

'html'          HTML format (default)
'text'          Text format
'active-html'   Includes Performance Hub active report

Enter value for report_type:

Type Specified:  html



Specify the location of AWR Data
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
AWR PDB reports can be generated using data stored in this PDB or ROOT.
Please enter the desired location at the prompt. Default value is 'AWR_PDB'.

    AWR_PDB  - Use AWR data from PDB
    AWR_ROOT - Use AWR data from ROOT
Enter value for awr_location:

Location of AWR Data Specified: AWR_PDB




Current Instance
~~~~~~~~~~~~~~~~
DB Id          DB Name        Inst Num       Instance       Container Name
-------------- -------------- -------------- -------------- --------------
 1899454952     DB1220                      1 DB1220         ORCLPDB1


Root DB Id      Container DB Id AWR DB Id
--------------- --------------- ---------------
   1467201108      1899454952      1899454952






Instances in this Workload Repository schema
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  DB Id      Inst Num   DB Name      Instance     Host
------------ ---------- ---------    ----------   ------
* 1899454952     1      DB1220       DB1220       ocp23c

Using 1899454952 for database Id
Using          1 for instance number

从以上输出可知,1467201108 是根容器的DBID,而1899454952 是PDB orclpdb1的DBID。

用以下SQL也可以验证:

SQL> show con_id;

CON_ID
------------------------------
1

SQL> select CON_ID_TO_DBID(1) from dual;

CON_ID_TO_DBID(1)
-----------------
       1467201108

SQL> alter session set container=orclpdb1;

Session altered.

SQL> show con_id;

CON_ID
------------------------------
3

SQL> select CON_ID_TO_DBID(3) from dual;

CON_ID_TO_DBID(3)
-----------------
       1899454952

SQL> select dbid from v$database;

      DBID
----------
1467201108

SQL> select dbid from v$pdbs;

      DBID
----------
1899454952

所以,结论就是,对于一个Oracle容器数据库,可以有多个DBID。

文章来源:https://blog.csdn.net/stevensxiao/article/details/135340110
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。