首页 > 开发 > 综合 > 正文

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

2024-07-21 02:11:23
字体:
来源:转载
供稿:网友
测试环境: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/[email protected] 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/[email protected] dbname=test3 setname=yes logfile=dbid.out

二、修改步骤如下:

1)、sql> conn sys/[email protected] 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/[email protected] 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 ystem01.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/[email protected] 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

菜鸟学堂:
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表