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
菜鳥學堂: