oracle dbnewid,使用DBNEWID Utility 修改oracle数据库的 db name 和 dbid

使用DBNEWID Utility 工具可以同时修改数据库名、DBID,也可以只修改其中一项

官方参考:

一、同时修改db name 和 dbid  (本例:emdb -> mydb)

1.修改之前建议给数据库做个全备。

2.干净关闭数据库,并重启到mount状态

shutdown immediate;

startup mount;

3.开始使用nid 工具修改数据库名和dbid

[oracle@Database ~]$ which nid

/u01/app/oracle/product/11.2.0.4/db_1/bin/nid

查看命令帮助:

[oracle@Database ~]$ nid -help

DBNEWID: Release 11.2.0.4.0 - Production on Tue Jun 5 15:03:50 2018

Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.

Keyword      Description                     (Default)

---------------------------------------------------------

TARGET    Username/Password         (NONE)

DBNAME    New database name         (NONE)

LOGFILE   Output Log                        (NONE)

REVERT    Revert failed change         NO

SETNAME Set a new database name only NO

APPEND    Append to output log          NO

HELP         Displays these messages   NO

[oracle@Database ~]$ nid target=sys dbname=mydb

DBNEWID: Release 11.2.0.4.0 - Production on Tue Jun 5 15:04:37 2018

Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.

Password:

Connected to database EMDB (DBID=2097101097)

Connected to server version 11.2.0

Control Files in database:

/u01/app/oracle/oradata/emdb/control01.ctl

/u01/app/oracle/oradata/emdb/control02.ctl

Change database ID and database name EMDB to MYDB? (Y/[N]) => y

Proceeding with operation

Changing database ID from 2097101097 to 2892995079

Changing database name from EMDB to MYDB

Control File /u01/app/oracle/oradata/emdb/control01.ctl - modified

Control File /u01/app/oracle/oradata/emdb/control02.ctl - modified

Datafile /u01/app/oracle/oradata/emdb/system01.db - dbid changed, wrote new name

Datafile /u01/app/oracle/oradata/emdb/sysaux01.db - dbid changed, wrote new name

Datafile /u01/app/oracle/oradata/emdb/undotbs01.db - dbid changed, wrote new name

Datafile /u01/app/oracle/oradata/emdb/users01.db - dbid changed, wrote new name

Datafile /u01/app/oracle/oradata/emdb/mgmt_ecm_depot1.db - dbid changed, wrote new name

Datafile /u01/app/oracle/oradata/emdb/mgmt.db - dbid changed, wrote new name

Datafile /u01/app/oracle/oradata/emdb/mgmt_deepdive.db - dbid changed, wrote new name

Datafile /u01/app/oracle/oradata/emdb/temp01.db - dbid changed, wrote new name

Control File /u01/app/oracle/oradata/emdb/control01.ctl - dbid changed, wrote new name

Control File /u01/app/oracle/oradata/emdb/control02.ctl - dbid changed, wrote new name

Instance shut down

Database name changed to MYDB.

Modify parameter file and generate a new password file before restarting.

Database ID for database MYDB changed to 2892995079.

All previous backups and archived redo logs for this database are unusable.

Database has been shutdown, open database with RESETLOGS option.

Succesfully changed database name and ID.

DBNEWID - Completed succesfully.

4.最后修改参数文件中的db_name

SQL> startup nomount;

ORACLE instance started.

Total System Global Area 1853947904 bytes

Fixed Size 2254264 bytes

Variable Size 939526728 bytes

Database Buffers 905969664 bytes

Redo Buffers 6197248 bytes

SQL> alter system set db_name='mydb' scope=spfile;

System altered.

SQL> shutdown immediate;

ORA-01507: database not mounted

ORACLE instance shut down.

5. 以resetlogs方式打开数据库

SQL> startup mount;

ORACLE instance started.

Total System Global Area 1853947904 bytes

Fixed Size 2254264 bytes

Variable Size 939526728 bytes

Database Buffers 905969664 bytes

Redo Buffers 6197248 bytes

Database mounted.

SQL> alter database open resetlogs;

二、只修改dbid (在使用nid 命令不加dbname参数即可)

[oracle@Database ~]$ nid target=sys dbname=mydb

三、只修改dbname  (在nid 命令中 加上 SETNAME=YES 选项,表示只修改数据库名称)

[oracle@Database ~]$ nid target=sys dbname=mydb SETNAME=YES

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值