使用Nid修改数据库名称
1.数据库当前设置:
SQL> select * from v$version;
BANNER
--------------------------------------------------------------------------------
Oracle Database
11g Enterprise Edition Release 11.2.0.3.0 - Production
PL/SQL Release 11.2.0.3.0 - Production
CORE 11.2.0.3.0 Production
TNS for Linux: Version 11.2.0.3.0 - Production
NLSRTL Version 11.2.0.3.0 - Production
SQL> show parameter name
NAME TYPE VALUE
------------------------------------ ---------------------- ------------------------------
db_file_name_convert string
db_name string chen
db_unique_name string chen
global_names boolean FALSE
instance_name string chen
lock_name_space string
log_file_name_convert string
processor_group_name string
service_names chen
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
[
oracle@localhost ~]$ nid target=sys/oracle dbname=newchen
DBNEWID: Release 11.2.0.3.0 - Production on 2 04:44:19 2012
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
Connected to database CHEN (DBID=1171122224)
Connected to server version 11.2.0
Control Files in database:
/opt/ora11g/oradata/chen/control01.ctl
/opt/ora11g/oradata/chen/control02.ctl
/opt/ora11g/oradata/chen/control03.ctl
Change database ID and database name CHEN to NEWCHEN? (Y/[N]) => Y
Proceeding with operation
Changing database ID from 1171122224 to 2466066852
Changing database name from CHEN to NEWCHEN
Control File /opt/ora11g/oradata/chen/control01.ctl - modified
Control File /opt/ora11g/oradata/chen/control02.ctl - modified
Control File /opt/ora11g/oradata/chen/control03.ctl - modified
Datafile /opt/ora11g/oradata/chen/system01.db - dbid changed, wrote new name
Datafile /opt/ora11g/oradata/chen/sysaux01.db - dbid changed, wrote new name
Datafile /opt/ora11g/oradata/chen/undotbs01.db - dbid changed, wrote new name
Datafile /opt/ora11g/oradata/chen/users01.db - dbid changed, wrote new name
Datafile /opt/ora11g/oradata/chen/temp01.db - dbid changed, wrote new name
Control File /opt/ora11g/oradata/chen/control01.ctl - dbid changed, wrote new name
Control File /opt/ora11g/oradata/chen/control02.ctl - dbid changed, wrote new name
Control File /opt/ora11g/oradata/chen/control03.ctl - dbid changed, wrote new name
Instance shut down
Database name changed to NEWCHEN.
Modify parameter file and generate a new password file before restarting.
Database ID for database NEWCHEN changed to 2466066852.
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=newchen
[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.
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