您的位置:首页 > 数据库 > Oracle

修改数据库名称, 方法适用于Oracle9iR2以后版本.

2009-02-23 16:31 435 查看
 参考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/
) => 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';
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
相关文章推荐