ORACLE 使用nid修改数据库名称

1.数据库当前设置:
SQL> select * from v$version;


BANNER
--------------------------------------------------------------------------------
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
PL/SQL Release 11.2.0.4.0 - Production
CORE    11.2.0.4.0      Production
TNS for Linux: Version 11.2.0.4.0 - Production
NLSRTL Version 11.2.0.4.0 - Production


SQL> 




------------------------------------------------------------------------------------------
SQL> show parameter name


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


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


2.Shutdown数据库:
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.


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


3.Startup mount :
SQL> startup mount
ORACLE instance started.
Total System Global Area  196681728 bytes
Fixed Size                       1343864 bytes
Variable Size                    88084104 bytes
Database Buffers             104857600 bytes
Redo Buffers                   2396160 bytes
Database mounted.


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


4. 使用NID更改:
SQL> host


nid target=sys/oracle@prdhtjc dbname=htjc01


oracle@prdhtjc1:/backup/rmanbackdir$nid target=sys/oracle@prdhtjc dbname=htjc01


DBNEWID: Release 11.2.0.4.0 - Production on Sun Jan 12 13:41:28 2014


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


Connected to database PRDHTJC (DBID=4253573492)


Connected to server version 11.2.0


Control Files in database:
    /dbfile/oradata/prdhtjc/control01.ctl
    /dbfile/oradata/prdhtjc/control02.ctl
    /dbfile/oradata/prdhtjc/control03.ctl


Change database ID and database name PRDHTJC to HTJC01? (Y/[N]) => Y


Proceeding with operation
Changing database ID from 4253573492 to 1038336969
Changing database name from PRDHTJC to HTJC01
    Control File /dbfile/oradata/prdhtjc/control01.ctl - modified
    Control File /dbfile/oradata/prdhtjc/control02.ctl - modified
    Control File /dbfile/oradata/prdhtjc/control03.ctl - modified
    Datafile /dbfile/oradata/prdhtjc/system01.db - dbid changed, wrote new name
    Datafile /dbfile/oradata/prdhtjc/sysaux01.db - dbid changed, wrote new name
    Datafile /dbfile/oradata/prdhtjc/undotbs01.db - dbid changed, wrote new name
    Datafile /dbfile/oradata/prdhtjc/users01.db - dbid changed, wrote new name
    Datafile /dbfile/oradata/prdhtjc/htjc01.db - dbid changed, wrote new name
    Datafile /dbfile/oradata/prdhtjc/htjc02.db - dbid changed, wrote new name
    Datafile /dbfile/oradata/prdhtjc/htjc03.db - dbid changed, wrote new name
    Datafile /dbfile/oradata/prdhtjc/htjc04.db - dbid changed, wrote new name
    Datafile /dbfile/oradata/prdhtjc/htjc05.db - dbid changed, wrote new name
    Datafile /dbfile/oradata/prdhtjc/htjc06.db - dbid changed, wrote new name
    Datafile /dbfile/oradata/prdhtjc/htjc07.db - dbid changed, wrote new name
    Datafile /dbfile/oradata/prdhtjc/htjc08.db - dbid changed, wrote new name
    Datafile /dbfile/oradata/prdhtjc/htjc09.db - dbid changed, wrote new name
    Datafile /dbfile/oradata/prdhtjc/htjc10.db - dbid changed, wrote new name
    Datafile /dbfile/oradata/prdhtjc/zuhe01.db - dbid changed, wrote new name
    Datafile /dbfile/oradata/prdhtjc/ptrd01.db - dbid changed, wrote new name
    Datafile /dbfile/oradata/prdhtjc/ptrd02.db - dbid changed, wrote new name
    Datafile /dbfile/oradata/prdhtjc/temp01.db - dbid changed, wrote new name
    Control File /dbfile/oradata/prdhtjc/control01.ctl - dbid changed, wrote new name
    Control File /dbfile/oradata/prdhtjc/control02.ctl - dbid changed, wrote new name
    Control File /dbfile/oradata/prdhtjc/control03.ctl - dbid changed, wrote new name
    Instance shut down


Database name changed to HTJC01.
Modify parameter file and generate a new password file before restarting.
Database ID for database HTJC01 changed to 1038336969.
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.


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


5.Shutdown database:
SQL> shutdown immediate
ORA-01109: database not open
Database dismounted.
ORACLE instance shut down.


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


6.修改初始化参数文件、spfile文件(init.ora/spfile):
instance_name=newchen
#instance_name=chen
db_domain=""
db_name=newchen
#db_name=chen


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


7.Startup mount,resetlogs打开:
[oracle@localhost dbs]$ export ORACLE_SID=htjc01
[oracle@localhost dbs]$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.3.0 Production on 2 04:59:39 2012
Copyright (c) 1982, 2011, Oracle.  All rights reserved.
Connected to an idle instance.
SQL> startup mount
ORACLE instance started.
Total System Global Area  196681728 bytes
Fixed Size                  1343864 bytes
Variable Size              83889800 bytes
Database Buffers          109051904 bytes
Redo Buffers                2396160 bytes
Database mounted.


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


Step8、修改数据库相关文件的路径名称:


select name from V$datafile;
select member from V$logfile;
select name from V$tempfile;




For exp:


alter database rename file '...' to '...';






SQL> alter database open resetlogs;
Database altered.




SQL> show parameter name
NAME                                 TYPE                   VALUE
------------------------------------ ---------------------- ------------------------------
db_file_name_convert             string
db_name                               string                 newchen
db_unique_name                    string                 newchen
global_names                         boolean                FALSE
instance_name                       string                 newchen
lock_name_space                    string
log_file_name_convert             string
processor_group_name            string
service_names                        string                 newchen
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值