oracle 更改 db_name 的方法

运行下面的命令,即可更改db_name 从haha 更改为test

>nid target=sys/gaokai@haha dbname=test

下面演示:

C:\Documents and Settings\andyleng>set ORACLE_SID=haha

C:\Documents and Settings\andyleng>sqlplus /nolog

SQL*Plus: Release 11.2.0.1.0 Production on Wed Nov 2 18:07:00 2011

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

SQL> conn /as sysdba
Connected to an idle instance.
SQL> startup
ORACLE instance started.

Total System Global Area  778387456 bytes
Fixed Size                  1374808 bytes
Variable Size             234882472 bytes
Database Buffers          536870912 bytes
Redo Buffers                5259264 bytes
Database mounted.
Database opened.
SQL> show parameter name

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
db_file_name_convert                 string
db_name                              string      haha
db_unique_name                       string      haha
global_names                         boolean     FALSE
instance_name                        string      haha
lock_name_space                      string
log_file_name_convert                string
service_names                        string      haha
SQL> create pfile from spfile;

File created.

SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Pr
oduction
With the Partitioning, OLAP, Data Mining and Real Application Testing options

C:\Documents and Settings\andyleng>

 

C:\Documents and Settings\andyleng>set ORACLE_SID=haha

C:\Documents and Settings\andyleng>sqlplus /nolog

SQL*Plus: Release 11.2.0.1.0 Production on Wed Nov 2 18:08:40 2011

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

SQL> conn /as sysdba
Connected to an idle instance.
SQL> startup mount;
ORACLE instance started.

Total System Global Area  778387456 bytes
Fixed Size                  1374808 bytes
Variable Size             234882472 bytes
Database Buffers          536870912 bytes
Redo Buffers                5259264 bytes
Database mounted.
SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Pr
oduction
With the Partitioning, OLAP, Data Mining and Real Application Testing options

C:\Documents and Settings\andyleng>nid target=sys/oracle@haha dbname=test

DBNEWID: Release 11.2.0.1.0 - Production on Wed Nov 2 18:11:10 2011

Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.

Connected to database HAHA (DBID=3533083211)

Connected to server version 11.2.0

Control Files in database:
    D:\ORACLE\ORADATA\TEST\CONTROL01.CTL
    D:\ORACLE\FLASH_RECOVERY_AREA\TEST\CONTROL02.CTL

Change database ID and database name HAHA to TEST? (Y/[N]) => y

Proceeding with operation
Changing database ID from 3533083211 to 2064306111
Changing database name from HAHA to TEST
    Control File D:\ORACLE\ORADATA\TEST\CONTROL01.CTL - modified
    Control File D:\ORACLE\FLASH_RECOVERY_AREA\TEST\CONTROL02.CTL - modified
    Datafile D:\ORACLE\ORADATA\TEST\SYSTEM01.DB - dbid changed, wrote new name
    Datafile D:\ORACLE\ORADATA\TEST\SYSAUX01.DB - dbid changed, wrote new name
    Datafile D:\ORACLE\ORADATA\TEST\UNDOTBS01.DB - dbid changed, wrote new name
    Datafile D:\ORACLE\ORADATA\TEST\USERS01.DB - dbid changed, wrote new name
    Datafile D:\ORACLE\ORADATA\TEST\ATG_TBS01.DB - dbid changed, wrote new name
    Datafile D:\ORACLE\ORADATA\TEST\ATG_LOBTBS01.DB - dbid changed, wrote new na
me
    Datafile D:\ORACLE\ORADATA\TEST\TEMP01.DB - dbid changed, wrote new name
    Control File D:\ORACLE\ORADATA\TEST\CONTROL01.CTL - dbid changed, wrote new
name
    Control File D:\ORACLE\FLASH_RECOVERY_AREA\TEST\CONTROL02.CTL - dbid changed
, wrote new name
    Instance shut down

Database name changed to TEST.
Modify parameter file and generate a new password file before restarting.
Database ID for database TEST changed to 2064306111.
All previous backups and archived redo logs for this database are unusable.
Database is not aware of previous backups and archived logs in Recovery Area.
Database has been shutdown, open database with RESETLOGS option.
Succesfully changed database name and ID.
DBNEWID - Completed succesfully.


C:\Documents and Settings\andyleng>ORADIM -del -sid haha
Instance deleted.

C:\Documents and Settings\andyleng>oradim -new -sid test
Instance created.

C:\Documents and Settings\andyleng>set ORACLE_SID=test

C:\Documents and Settings\andyleng>sqlplus /nolog

SQL*Plus: Release 11.2.0.1.0 Production on Wed Nov 2 18:12:50 2011

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

SQL> conn /as sysdba
Connected to an idle instance.
SQL> startup
ORACLE instance started.

Total System Global Area  778387456 bytes
Fixed Size                  1374808 bytes
Variable Size             427820456 bytes
Database Buffers          343932928 bytes
Redo Buffers                5259264 bytes
Database mounted.
ORA-01589: must use RESETLOGS or NORESETLOGS option for database open


SQL> create spfile from pfile;

File created.

SQL> alter database open resetlogs;

Database altered.

SQL> show parameter name

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
db_file_name_convert                 string
db_name                              string      test
db_unique_name                       string      test
global_names                         boolean     FALSE
instance_name                        string      test
lock_name_space                      string
log_file_name_convert                string
service_names                        string      test
SQL>


 

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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值