nid更改db_name与dbid:

1. Ramifications后果 of Changing the DBID and DBNAME:
Changing the DBID of a database is a serious procedure. This is similar to creating a database except that the data is already in the datafiles. 
After you change the DBID, backups and archive logs that were created prior to the change can no longer be used because they still have the original DBID, which does not match the current DBID. 
You must open the database with the RESETLOGS option, which re-creates the online redo logs and resets their sequence to 1. 
Consequently, you should make a backup of the whole database immediately after changing the DBID.

Changing the DBNAME without changing the DBID does not require you to open with the RESETLOGS option, so database backups and archived logs are not invalidated. 
However, changing the DBNAME does have consequences. You must change the DB_NAME initialization parameter after a database name change to reflect the new name. Also, you may have to re-create the Oracle password file. 
If you restore an old backup of the control file (before the name change), then you should use the initialization parameter file and password file from before the database name change.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2. nid
$ nid -help 
DBNEWID: Release 12.2.0.1.0 - Production on Wed Dec 16 14:08:01 2020
Copyright (c) 1982, 2017, Oracle and/or its affiliates.  All rights reserved.
Keyword     Description                    (Default)
----------------------------------------------------
TARGET      Username/Password                (NONE)     --需要sysdba权限
DBNAME      New database name              (NONE)
LOGFILE     Output Log                               (NONE)
REVERT      Revert还原 failed change              NO    
SETNAME   Set a new database name only    NO    --不更改dbid
APPEND      Append to output log                 NO
HELP        Displays these messages                 NO
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

3. 过程:
SQL> alter system set instance_name=ocp scope=spfile;
SQL> alter system set service_names=ocp scope=spfile;
SQL> alter system set db_unique_name=ocp scope=spfile;
SQL> shutdown immediate
SQL> startup mount;
$ nid target=sys/sys@orcl dbname=ocp
DBNEWID: Release 10.2.0.4.0 - Production on Mon Jul 1 11:16:09 2013
Copyright (c) 1982, 2007, Oracle.  All rights reserved.
Connected to database SKYREAD (DBID=148366931)            ----★★★★★★★★
Connected to server version 10.2.0
Control Files in database:
    /database/oradata/skyread/control01.ctl
    /database/oradata/skyread/control02.ctl
    /database/oradata/skyread/control03.ctl
Change database ID of database SKYREAD? (Y/[N]) => y            ----★★★★★★★★
Proceeding with operation
Changing database ID from 148366931 to 277140985        ----★★★★★★★★
    Control File /database/oradata/skyread/control01.ctl - modified
    Control File /database/oradata/skyread/control02.ctl - modified
    Control File /database/oradata/skyread/control03.ctl - modified
    Datafile /database/oradata/skyread/system01.dbf - dbid changed
    Datafile /database/oradata/skyread/tbs_test.dbf - dbid changed
    Datafile /database/oradata/skyread/sysaux01.dbf - dbid changed
    Datafile /database/oradata/skyread/users01.dbf - dbid changed
    Datafile /database/oradata/skyread/system02.dbf - dbid changed
    Datafile /database2/oradata/skyread/undotbs02.dbf - dbid changed
    Datafile /database2/oradata/skyread/TBS_MRPMUSIC01.dbf - dbid changed
    Datafile /database/oradata/skyread/sf01.dbf - dbid changed
    Control File /database/oradata/skyread/control01.ctl - dbid changed
    Control File /database/oradata/skyread/control02.ctl - dbid changed
    Control File /database/oradata/skyread/control03.ctl - dbid changed
    Instance shut down                    

Database ID for database SKYREAD changed to 277140985.            
All previous backups and archived redo logs for this database are unusable.    
Database is not aware of previous backups and archived logs in Recovery Area.    
Database has been shutdown, open database with RESETLOGS option.        
Succesfully changed database ID.
DBNEWID - Completed succesfully.

$ orapwd file=$ORACLE_HOME/dbs/orapwocp password=oracle
SQL> startup nomount
SQL> alter system set db_name=ocp scope=spfile;
SQL> shutdown immediate
SQL> startup mount
SQL> alter database open resetlogs;
SQL>  select dbid from v$database;    -- 277140985
SQL> show parameter name
注:如果要使用OEM,需要重建
使用nid命令修改db_name和dbid的方法仅适用于Oracle10g及以后版本,Oracle9i之前版本不适用

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值