脚踏实地、勇往直前!
全部博文(1005)
分类: Oracle
2012-03-11 19:35:27
下面通过nid更改db_name和dbid:
1.加载数据库,nid需要数据库在mount下执行
sql>startup mount
2.将数据名更改为oraclstr,这里没有设置setname,说明dbid也一同更改
[oracle@hxl_str ~]$ nid target=sys/sys dbname=oraclstr
DBNEWID: Release 10.2.0.1.0 - Production on Mon Mar 12 02:29:35 2012
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Connected to database ORACL (DBID=1823104615)
Connected to server version 10.2.0
Control Files in database:
/u01/app/oracle/oradata/oracl/control01.ctl
/u01/app/oracle/oradata/oracl/control02.ctl
/u01/app/oracle/oradata/oracl/control03.ctl
Change database ID and database name ORACL to ORACLSTR? (Y/[N]) => Y
Proceeding with operation
Changing database ID from 1823104615 to 4148550416
Changing database name from ORACL to ORACLSTR
Control File /u01/app/oracle/oradata/oracl/control01.ctl - modified
Control File /u01/app/oracle/oradata/oracl/control02.ctl - modified
Control File /u01/app/oracle/oradata/oracl/control03.ctl - modified
Datafile /u01/app/oracle/oradata/oracl/system01.dbf - dbid changed, wrote new name
Datafile /u01/app/oracle/oradata/oracl/undotbs01.dbf - dbid changed, wrote new name
Datafile /u01/app/oracle/oradata/oracl/sysaux01.dbf - dbid changed, wrote new name
Datafile /u01/app/oracle/oradata/oracl/users01.dbf - dbid changed, wrote new name
Datafile /u01/app/oracle/oradata/oracl/temp01.dbf - dbid changed, wrote new name
Control File /u01/app/oracle/oradata/oracl/control01.ctl - dbid changed, wrote new name
Control File /u01/app/oracle/oradata/oracl/control02.ctl - dbid changed, wrote new name
Control File /u01/app/oracle/oradata/oracl/control03.ctl - dbid changed, wrote new name
Instance shut down
Database name changed to ORACLSTR.
Modify parameter file and generate a new password file before restarting.
Database ID for database ORACLSTR changed to 4148550416.
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.
3.修改oracle用户的环境变量(若不想修改oracle_sid,这步可以省略)
编辑.bash_profile,修改ORACLE_SID=oraclstr
4.修改参数文件
4.1 生成初始化参数便于修改
create pfile='/u01/app/oracle/product/10.2.0/db_1/dbs/initoraclstr.ora' from spfile
编辑initoracl.ora
修改将db_name修改如下
db_name=oraclstr
4.2 创建spfile
create spfile from pfile='/u01/app/oracle/product/10.2.0/db_1/dbs/initoraclstr.ora';
如没有修改db_name参数的话启动的时候会报如下错误:
SQL> startup
ORACLE instance started.
Total System Global Area 734003200 bytes
Fixed Size 1221564 bytes
Variable Size 201329732 bytes
Database Buffers 528482304 bytes
Redo Buffers 2969600 bytes
ORA-01103: database name 'ORACLSTR' in control file is not 'ORACL'
5.创建密码文件
orapwd file='/u01/app/oracle/product/10.2.0/db_1/dbs/orapworalstr' password=sys entries=10 force=y
--The End--