9I中如何修改Ddid和Dbname方法测试小结

发表于:2007-05-25来源:作者:点击数: 标签:
测试环境 : Windows 2000 + Oracle 9.2.0.1 具体操作如下: 一、NID工具使用 :(oracle工具,数据库安装完成后,就自动安装了),具体用法如看; C:\nid DBNEWID: Release 9.2.0.1.0 - Production Copyright (c) 1995, 2002, Oracle Corporation.All rights
测试环境Windows2000 + Oracle 9.2.0.1
具体操作如下:
一、NID工具使用:(oracle工具,数据库安装完成后,就自动安装了),具体用法如看;
C:\>nid
DBNEWID: Release 9.2.0.1.0 - Production
Copyright (c) 1995, 2002, Oracle Corporation.  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

用法举例:
Changing Only the DBID
The following example connects with operating system authentication and changes only the DBID:

% nid TARGET=/

Changing the DBID and Database Name
The following example connects as user SYS and changes the DBID and also changes the database name to test2:

% nid TARGET=SYS/oracle@test1 DBNAME=test2

Changing Only the Database Name
The following example connects as user SYSTEM and changes only the database name, and also specifies a log file for the output:

% nid TARGET=SYSTEM/manager@test2 DBNAME=test3 SETNAME=YES LOGFILE=dbid.out

二、修改步骤如下:

1)、SQL> conn sys/admin@test as sysdba
Connected.
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL>
SQL> startup mount
ORACLE instance started.

Total System Global Area  101784276 bytes
Fixed Size                   453332 bytes
Variable Size              75497472 bytes
Database Buffers           25165824 bytes
Redo Buffers                 667648 bytes
Database mounted.
SQL> host nid target=sys/admin@test dbname=testdb
DBNEWID: Release 9.2.0.1.0 - Production
Copyright (c) 1995, 2002, Oracle Corporation.  All rights reserved.

Connected to database TEST (DBID=1835076349)

Control Files in database:
    C:\ORACLE\ORADATA\TEST\CONTROL01.CTL
    C:\ORACLE\ORADATA\TEST\CONTROL02.CTL
    C:\ORACLE\ORADATA\TEST\CONTROL03.CTL

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

Proceeding with operation
Changing database ID from 1835076349 to 2321050327
Changing database name from TEST to TESTDB
    Control File C:\ORACLE\ORADATA\TEST\CONTROL01.CTL - modified
    Control File C:\ORACLE\ORADATA\TEST\CONTROL02.CTL - modified
    Control File C:\ORACLE\ORADATA\TEST\CONTROL03.CTL - modified
    Datafile C:\ORACLE\ORADATA\TEST\SYSTEM01.DBF - dbid changed, wrote new name
    Datafile C:\ORACLE\ORADATA\TEST\UNDOTBS01.DBF - dbid changed, wrote new nam

    Datafile C:\ORACLE\ORADATA\TEST\INDX01.DBF - dbid changed, wrote new name
    Datafile C:\ORACLE\ORADATA\TEST\TOOLS01.DBF - dbid changed, wrote new name
    Datafile C:\ORACLE\ORADATA\TEST\USERS01.DBF - dbid changed, wrote new name
    Datafile D:\DATAFILE\PORMALS_SPA.DBF - dbid changed, wrote new name
    Datafile C:\ORACLE\ORADATA\TEST\OEM_REPOSITORY.DBF - dbid changed, wrote ne
name
    Datafile D:\DATAFILE\PORMALS_SPA_01.DBF - dbid changed, wrote new name
    Datafile C:\ORACLE\ORADATA\TEST\TEMP01.DBF - dbid changed, wrote new name
    Control File C:\ORACLE\ORADATA\TEST\CONTROL01.CTL - dbid changed, wrote new
name
    Control File C:\ORACLE\ORADATA\TEST\CONTROL02.CTL - dbid changed, wrote new
name
    Control File C:\ORACLE\ORADATA\TEST\CONTROL03.CTL - dbid changed, wrote new
name

Database name changed to TESTDB.
Modify parameter file and generate a new password file before restarting.
Database ID for database TESTDB changed to 2321050327.
All previous backups and archived redo logs for this database are unusable.
Shut down database and open with RESETLOGS option.
Succesfully changed database name and ID.
DBNEWID - Completed succesfully.
2)立即关闭数据库,修改db_name参数
SQL> shutdown immediate
ORA-01109: database not open
Database dismounted.
ORACLE instance shut down.

在spfile文件里作相应修改,数据库db_name
SQL>startup mount;
SQL>alter system set db_name=testdb scope=spfile;

System altered.
注:如果是pfile文件,需手工修改db_name参数值
3)重新创建密码文件
SQL>host orapwd file=c:\oracle\ora92\database\pwwdtestdb.ora password=admin entries=8
SQL> conn sys/admin@test as sysdba
Connected to an idle instance.

4)、以Resetlogs选项打开数据库
SQL> startup mount
ORACLE 例程已经启动。

Total System Global Area  135338868 bytes
Fixed Size                   453492 bytes
Variable Size             109051904 bytes
Database Buffers           25165824 bytes
Redo Buffers                 667648 bytes
数据库装载完毕。
SQL> alter database open resetlogs;

数据库已更改。
5)、查看修改是构成功
SQL> select dbid,name from v$database;

      DBID NAME
---------- ---------
2321050327 TESTDB

SQL>

注意:2、3不能颠倒,否则,重建口令文件是不可用的

参考文档:http://download-west.oracle.com/ ... 52/ch14.htm#1004918


原文转自:http://www.ltesting.net