oracle 修改数据库名,修改oracle数据库名

在测试使用rman复制数据库时,之前为了好区分,我把一个数据库命名为standby,但是貌似这是个保留字,不能使用。又不想重新建数,所以想修改数据库名。

修改数据库名有两种方法:一种方法是重建控制文件,一种方法是使用DBNEWID工具。重建控制文件步骤比较繁杂,所以我使用DBNEWID工具。

1,正常关闭数据库

sqlplus / as sysdba

SQL>shutdown immediate

2,启动数据库到mount模式

SQL>startup mount

3,确认LISTENER是启动的

lsnrctl status

LSNRCTL for Linux: Version 10.2.0.5.0 - Production on 09-DEC-2010 09:36:00

Copyright (c) 1991, 2010, Oracle.  All rights reserved.

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=redhat6)(PORT=1521)))

STATUS of the LISTENER

------------------------

Alias                     LISTENER

Version                   TNSLSNR for Linux: Version 10.2.0.5.0 - Production

Start Date                09-DEC-2010 09:34:47

Uptime                    0 days 0 hr. 1 min. 12 sec

Trace Level               off

Security                  ON: Local OS Authentication

SNMP                      OFF

Listener Parameter File   /u01/soft/product/10.2.0/db_1/network/admin/listener.ora

Listener Log File         /u01/soft/product/10.2.0/db_1/network/log/listener.log

Listening Endpoints Summary...

(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=redhat6)(PORT=1521)))

(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC0)))

Services Summary...

Service "PLSExtProc" has 1 instance(s).

Instance "PLSExtProc", status UNKNOWN, has 1 handler(s) for this service...

Service "standby" has 1 instance(s).

Instance "standby", status READY, has 1 handler(s) for this service...

Service "standby_XPT" has 1 instance(s).

Instance "standby", status READY, has 1 handler(s) for this service...

The command completed successfully

4,修改数据库名。使用DBNEWID工具修改数据库名时,比较以sysdba登录数据库,且要指定修改后的数据库名和使用setname选项。

nid target=sys/sys@standby dbname=demo setname=y

DBNEWID: Release 10.2.0.5.0 - Production on Thu Dec 9 09:36:04 2010

Copyright (c) 1982, 2007, Oracle.  All rights reserved.

Connected to database STANDBY (DBID=1547703384)

Connected to server version 10.2.0

Control Files in database:

/u01/soft/oradata/standby/control01.ctl

/u01/soft/oradata/standby/control02.ctl

/u01/soft/oradata/standby/control03.ctl

Change database name of database STANDBY to DEMO? (Y/[N]) => y

Proceeding with operation

Changing database name from STANDBY to DEMO

Control File /u01/soft/oradata/standby/control01.ctl - modified

Control File /u01/soft/oradata/standby/control02.ctl - modified

Control File /u01/soft/oradata/standby/control03.ctl - modified

Datafile /u01/soft/oradata/standby/system01.dbf - wrote new name

Datafile /u01/soft/oradata/standby/undotbs01.dbf - wrote new name

Datafile /u01/soft/oradata/standby/sysaux01.dbf - wrote new name

Datafile /u01/soft/oradata/standby/users01.dbf - wrote new name

Datafile /u01/soft/oradata/standby/temp01.dbf - wrote new name

Control File /u01/soft/oradata/standby/control01.ctl - wrote new name

Control File /u01/soft/oradata/standby/control02.ctl - wrote new name

Control File /u01/soft/oradata/standby/control03.ctl - wrote new name

Instance shut down

Database name changed to DEMO.

Modify parameter file and generate a new password file before restarting.

Succesfully changed database name.

DBNEWID - Completed succesfully.

5,修改参数文件,把原来的DB_NAME=standby修改为DB_NAME=demo

6,重新密码文件,orapwd file=/u01/soft/product/10.2.0/db_1/dbs/orapwdemo password=admin

7,使用修改后的pfile文件启动数据库

SQL> startup pfile='/u01/soft/admin/standby/pfile/init.ora.1025201033256'

8,创建spfile

SQL> create spfile from pfile='/u01/soft/admin/standby/pfile/init.ora.1025201033256';

9,重新启动数据库

SQL> shutdown immediate

SQL> startup

下面是nid命令的参数信息:

DBNEWID: Release 10.2.0.5.0 - Production on Thu Dec 9 09:50:02 2010

Copyright (c) 1982, 2007, 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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值