某些系統是因為Oracle數據庫的名稱不是很規范,如果你不想對Oracle數據庫重新創建的話,你可以使用Oracle自帶的工具即nid來修改Oracle數據庫的名稱。在整個修改過程中,對控制文件和數據文件進行修改,且重置dbid,建議在修改前對數據進行備份。
在本例子中,我們將Oracle數據庫中的instance_name和db_name從“oratest”修改為“test”,數據庫版本為10.2.0.3。
查看數據庫信息。
- SQL> show parameter instance_name
- NAME TYPE VALUE
- stance_name string ORATEST
- SQL> show parameter db_name
- NAME TYPE VALUE
- db_name string ORATEST
- SQL>show parameter service_name
- NAME TYPE VALUE
- db_name string ORATEST
- SQL>select dbid from v$database;
- DBID
- 3213300265
修改前Oracle數據庫名為"oratest",dbid="3213300265"。接下來修改數據庫名稱,先停止數據庫,然後啟動到mount狀態下,使用nid工具修改dbname。
- SQL> shutdown immediate
- Database closed.
- Database dismounted.
- Oracle instance shut down.
- SQL> startup mount
- Total System Global Area 268435456 bytes
- Fixed Size 1261272 bytes
- Variable Size 117440808 bytes
- Database Buffers 146800640 bytes
- Redo Buffers 2932736 bytes
- Database mounted.
- SQL> host;
- $ nid target="sys/passWord" dbname=test
- DBNEWID: Release 10.2.0.3.0 - Production on Wed Feb 4 11:12:36 2009
- Copyright (c) 1982, 2005, Oracle. All rights reserved.
- Connected to database ORATEST (DBID=3213300265)
- Connected to server version 10.2.0
- Control Files in database:
- /u02/oradata/test/control01.ctl
- /u02/oradata/test/control02.ctl
- /u02/oradata/test/control03.ctl
- Change database ID and database name ORATEST to TEST? (Y/[N]) => y
- Proceeding with Operation
- Changing database ID from 3213300265 to 1976074532
- Changing database name from ORATEST to TEST
- Control File /u02/oradata/test/control01.ctl - modifIEd
- Control File /u02/oradata/test/control02.ctl - modifIEd
- Control File /u02/oradata/test/control03.ctl - modifIEd
- Datafile /u02/oradata/test/system01.dbf - dbid changed, wrote new name
- Datafile /u02/oradata/test/undotbs01.dbf - dbid changed, wrote new name
- Datafile /u02/oradata/test/sysaux01.dbf - dbid changed, wrote new name
- Datafile /u02/oradata/test/users01.dbf - dbid changed, wrote new name
- Datafile /u02/oradata/test/example01.dbf - dbid changed, wrote new name
- Datafile /u02/oradata/test/temp01.dbf - dbid changed, wrote new name
- Control File /u02/oradata/test/control01.ctl - dbid changed, wrote new name
- Control File /u02/oradata/test/control02.ctl - dbid changed, wrote new name
- Control File /u02/oradata/test/control03.ctl - dbid changed, wrote new name
- NID-00600: Internal Error - [28] [12152] [0] [0]
- Change of database name and ID failed during validation -database is intact.
- DBNEWID - Completed with validation errors.