WAYS TO FIND DBID IN ORACLE
Whenever backup is triggered in database, you can always redirect the output to a log file to save DBID to output file.
Drawback: we cant get the DBID, if database is in nomount state
[oracle@orcl19x ~]$ exit|rman target / > dbid
[oracle@orcl19x ~]$ cat dbid
Recovery Manager: Release 12.1.0.2.0 - Production on Tue May 18 23:03:23 2021
Copyright (c) 1982, 2014, Oracle and/or its affiliates. All rights reserved.
connected to target database: ORCL19X (DBID=4048647388, not open)
RMAN>
Recovery Manager complete.
From sqlplus prompt ,you can get the dbid using sql query.
Drawback: But in case if your database is in nomount stage,then you cant get DBID.
SQL> select dbid,name from v$database;
DBID NAME
---------- ---------
4048647388 ORCL19X
Controlfile autobackup with %F format can create backup pieces with DBID
Note: Always make this as a practice for controlfile backup and not to worry as by default if you enable autobackup, you will get dbid on the backup piece
RMAN> CONFIGURE CONTROLFILE AUTOBACKUP ON;
new RMAN configuration parameters:
CONFIGURE CONTROLFILE AUTOBACKUP ON;
new RMAN configuration parameters are successfully stored
RMAN> backup datafile 1;
Starting backup at 19-MAY-21
using channel ORA_DISK_1
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00001 name=/apps01/oradata/orcl19xsystem01.dbf
channel ORA_DISK_1: starting piece 1 at 19-MAY-21
channel ORA_DISK_1: finished piece 1 at 19-MAY-21
piece handle=/apps01/product/12.1.0/dbhome_1/dbs/0evv94n6_1_1 tag=TAG20210519T213638 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:01:25
Finished backup at 19-MAY-21
Starting Control File and SPFILE Autobackup at 19-MAY-21
piece handle=/apps01/product/12.1.0/dbhome_1/dbs/c-4048647388-20210519-00 comment=NONE
Finished Control File and SPFILE Autobackup at 19-MAY-21
Check for DBID in dbwr and m000 trace files
[oracle@orcl19x trace]$ grep 'Db ID=' *|grep -v grep
orcl19x_dbw0_2610.trc: Db ID=4048115338=0xf149568a, Db Name='ORCL19X'
orcl19x_dbw0_2610.trc: PDB ID=0, PDB Db ID=0=0x0
orcl19x_dbw0_2610.trc: Db ID=4048115338=0xf149568a, Db Name='ORCL19X'
orcl19x_dbw0_2610.trc: PDB ID=0, PDB Db ID=0=0x0
orcl19x_dbw0_2870.trc: Db ID=4048115338=0xf149568a, Db Name='ORCL19X'
orcl19x_dbw0_2870.trc: PDB ID=0, PDB Db ID=0=0x0
orcl19x_dbw0_2870.trc: Db ID=4048115338=0xf149568a, Db Name='ORCL19X'
orcl19x_dbw0_2870.trc: PDB ID=0, PDB Db ID=0=0x0
orcl19x_dbw0_2871.trc: Db ID=4048115338=0xf149568a, Db Name='ORCL19X'
orcl19x_dbw0_2871.trc: PDB ID=0, PDB Db ID=0=0x0
orcl19x_dbw0_2871.trc: Db ID=4048115338=0xf149568a, Db Name='ORCL19X'
orcl19x_dbw0_2871.trc: PDB ID=0, PDB Db ID=0=0x0
orcl19x_dbw0_2874.trc: Db ID=4048115338=0xf149568a, Db Name='ORCL19X'
orcl19x_dbw0_2874.trc: PDB ID=0, PDB Db ID=0=0x0
orcl19x_dbw0_2874.trc: Db ID=4048115338=0xf149568a, Db Name='ORCL19X'
orcl19x_dbw0_2874.trc: PDB ID=0, PDB Db ID=0=0x0
orcl19x_m000_5858.trc: Db ID=0=0x0, Db Name=''
orcl19x_m000_5858.trc: PDB ID=0, PDB Db ID=0=0x0
orcl19x_m000_5858.trc: Db ID=4048647388=0xf15174dc, Db Name='ORCL19X'
orcl19x_m000_5858.trc: PDB ID=0, PDB Db ID=0=0x0
orcl19x_m000_5858.trc: Db ID=4048647388=0xf15174dc, Db Name='ORCL19X'
orcl19x_m000_5858.trc: PDB ID=0, PDB Db ID=0=0x0
orcl19x_m000_5858.trc: Db ID=4048647388=0xf15174dc, Db Name='ORCL19X'
orcl19x_m000_5858.trc: PDB ID=0, PDB Db ID=0=0x0
Dump the logfile to trace to find the DBID
SQL> alter system dump logfile '/apps01/oradata/orcl19xredo01.log';
System altered.
[oracle@orcl19x trace]$ grep 'Db ID=' orcl19x_ora_9104.trc
Db ID=4048647388=0xf15174dc, Db Name='ORCL19X'
Dump the sysaux datafile to trace find the DBID
Benefit: DBID can be fetched from nomount state
SQL> alter system dump datafile '/apps01/oradata/orcl19xsysaux01.dbf' block min 1 block max 6;
System altered.
[oracle@orcl19x trace]$ grep 'Db ID=' orcl19x_ora_9217.trc
Db ID=4048647388=0xf15174dc, Db Name='ORCL19X'
Db ID=4048647388=0xf15174dc, Db Name='ORCL19X'