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

 参考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';

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值