[20130618]改变dbid.txt_just play!.txt
参考链接:
http://www.pythian.com/blog/how-to-choose-your-oracle-database-id-dbid/
修改数据库的dbid,一般可以选择nid工具,或者alter database open resetlogs打开.但是无法控制修改为什么数值!
按照上面的链接做一个测试,不要在生产系统上做这种操作.
SQL> select name, dbid from v$database ;
NAME DBID
-------------------- ----------
TEST 2071943378
sqlplus / as sysdba
shutdown immediate;
startup open read only;
执行如下命令:[注:数据库名我没有修改]
var old_name varchar2(20)
var old_dbid number
var new_name varchar2(20)
var new_dbid number
exec select name, dbid into :old_name,:old_dbid from v$database
print old_name
accept new_name prompt "Enter the new Database Name:"
accept new_dbid prompt "Enter the new Database ID:"
exec :new_name:='&&new_name'
exec :new_dbid:=&&new_dbid
set serveroutput on
exec dbms_output.put_line('Convert '||:old_name|| -
'('||to_char(:old_dbid)||') to '||:new_name|| -
'('||to_char(:new_dbid)||')')
declare
v_chgdbid binary_integer;
v_chgdbname binary_integer;
v_skipped binary_integer;
begin
dbms_backup_restore.nidbegin(:new_name,:old_name,:new_dbid,:old_dbid,0,0,10);
dbms_backup_restore.nidprocesscf(v_chgdbid,v_chgdbname);
dbms_output.put_line('ControlFile:');
dbms_output.put_line(' => Change Name:' ||to_char(v_chgdbname));
dbms_output.put_line(' => Change DBID:' ||to_char(v_chgdbid));
for i in (select file#,name from v$datafile)
loop
dbms_backup_restore.nidprocessdf(i.file#,0, v_skipped,v_chgdbid,v_chgdbname);
dbms_output.put_line('DataFile:'||i.name);
dbms_output.put_line(' => Skipped:' ||to_char(v_skipped));
dbms_output.put_line(' => Change Name:' ||to_char(v_chgdbname));
dbms_output.put_line(' => Change DBID:' ||to_char(v_chgdbid));
end loop;
for i in (select file#,name from v$tempfile)
loop
dbms_backup_restore.nidprocessdf(i.file#,1, v_skipped,v_chgdbid,v_chgdbname);
dbms_output.put_line('DataFile:'||i.name);
dbms_output.put_line(' => Skipped:' ||to_char(v_skipped));
dbms_output.put_line(' => Change Name:' ||to_char(v_chgdbname));
dbms_output.put_line(' => Change DBID:' ||to_char(v_chgdbid));
end loop;
dbms_backup_restore.nidend;
end;
/
RMAN> list incarnation;
using target database control file instead of recovery catalog
List of Database Incarnations
DB Key Inc Key DB Name DB ID STATUS Reset SCN Reset Time
------- ------- -------- ---------------- --- ---------- ----------
1 1 TEST 1 CURRENT 3230431872 2013-06-04 09:52:43
重新启动数据库,需要执行 alter database open resetlogs ;
RMAN> list incarnation;
using target database control file instead of recovery catalog
List of Database Incarnations
DB Key Inc Key DB Name DB ID STATUS Reset SCN Reset Time
------- ------- -------- ---------------- --- ---------- ----------
1 1 TEST 1 PARENT 3230431872 2013-06-04 09:52:43
2 2 TEST 1 CURRENT 3231164707 2013-06-18 17:20:27