参考metalink: DOC ID 224266.1, 方法适用于Oracle9iR2以后版本.
1. Backup the database
2. SHUTDOWN IMMEDIATE of the database
3. STARTUP MOUNT
4. Open one session and run NID with sysdba privileges
% nid TARGET=SYS/password@test_db DBNAME=test_db2 SETNAME=Y
- the value of DBNAME is the new dbname of the database
- SETNAME must be set to Y. The default is N and causes the DBID to be changed also.
5. shutdown IMMEDIATE of the database
6. Set the DB_NAME initialization parameter in the initialization parameter file to the new database name
7. Create a new password file
8. Startup of the database(without resetlogs)
举例:
$ sqlplus / as sysdba
SQL> show parameter db_name
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
db_name string WENDING
SQL> create pfile='/orahome/init.ora' from spfile;
SQL> shutdown immediate
SQL> startup mount
SQL> exit;
$ nid target=/ dbname=ESUITE setname=y
DBNEWID: Release 10.2.0.1.0 - Production on Wed Dec 31 16:07:11 2008
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Connected to database WENDING (DBID=270220430)
Connected to server version 10.2.0
Control Files in database:
/orahome/oradata/WENDING/control1.ctl
/orahome/oradata/WENDING/control2.ctl
/orahome/oradata/WENDING/control3.ctl
Change database name of database WENDING to ESUITE? (Y/[N]) => y
Proceeding with operation
Changing database name from WENDING to ESUITE
Control File /orahome/oradata/WENDING/control1.ctl - modified
Control File /orahome/oradata/WENDING/control2.ctl - modified
Control File /orahome/oradata/WENDING/control3.ctl - modified
Datafile /orahome/oradata/WENDING/system.dbf - wrote new name
Datafile /orahome/oradata/WENDING/undotbs1.dbf - wrote new name
Datafile /orahome/oradata/WENDING/sysaux.dbf - wrote new name
...
Datafile /orahome/oradata/WENDING/EUNITE_USER01.dbf - wrote new name
Datafile /orahome/oradata/WENDING/EUNITE_INDEX01.dbf - wrote new name
Datafile /orahome/oradata/WENDING/temp01.dbf - wrote new name
Control File /orahome/oradata/WENDING/control1.ctl - wrote new name
Control File /orahome/oradata/WENDING/control2.ctl - wrote new name
Control File /orahome/oradata/WENDING/control3.ctl - wrote new name
Instance shut down
Database name changed to ESUITE.
Modify parameter file and generate a new password file before restarting.
Succesfully changed database name.
DBNEWID - Completed succesfully.
$ vi /orahome/init.ora (修改db_name='ESUITE')
$ orapwd file=$ORACLE_HOME/dbs/orapw$ORACLE_SID password=iamwangnc force=y
$ sqlplus / as sysdba
SQL> startup pfile='/orahome/init.ora';
SQL> show parameter db_name
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
db_name string ESUITE
SQL> create spfile from pfile='/orahome/init.ora';
修改数据库名称, 方法适用于Oracle9iR2以后版本.
最新推荐文章于 2023-07-11 18:10:29 发布