nid是Oracle用来更改数据库名称的自带工具.它可以直接修改数据库名称,而无需通过以前需要重建控制文件的方法来改变.
nid命令的使用方法如下:
C:\WINDOWS>nid
DBNEWID: Release 10.2.0.1.0 – Production on Thu May 22 21:56:48 2008
Copyright (c) 1982, 2005, Oracle. 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
下面是使用nid修改数据名称的库实验:
实验环境:WinXP SP2
数据库版本:10.2.0.1
注:其中有些步骤可能是不需要的,主要是为了说明nid执行的两个条件:
1、数据库必须处于mount状态
2、所有的数据文件不能处于disabled状态
具体实验步骤:
1.使用nid将数据库名称由test改为t,但是提示错误:数据库不能处于open的状态
C:\WINDOWS>nid target=sys/test@test dbname=t
DBNEWID: Release 10.2.0.1.0 – Production on Thu May 22 21:58:33 2008
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Connected to database TEST (DBID=1946053558)
NID-00121: Database should not be open
Change of database name failed during validation – database is intact.
DBNEWID – Completed with validation errors.
2.关闭数据库,并启动到mount状态
sys@TEST>shut immediate
Database closed.
Database dismounted.
ORACLE instance shut down.sys@TEST>startup mount
ORACLE instance started.
Total System Global Area 268435456 bytes
Fixed Size 1248504 bytes
Variable Size 134218504 bytes
Database Buffers 125829120 bytes
Redo Buffers 7139328 bytes
Database mounted.
3.再次运行nid命令,又报了错,说有数据文件处于disabled的状态
C:\WINDOWS>nid target=sys/test@test dbname=t