下面修改数据库的SID和db_name
[root@oracle ~]# su - ora11gdb11@oracle /home/ora11g$db11@oracle /home/ora11g$ sqlplus /as sysdbaSQL*Plus:Release11.2.0.4.0Production on MonMar3007:39:362015Copyright(c)1982,2013,Oracle.All rights reserved.Connected to:OracleDatabase11gEnterpriseEditionRelease11.2.0.4.0-64bitProductionWith the Partitioning, OLAP,DataMiningandRealApplicationTesting optionsSQL>select name, dbid,log_mode,open_mode from v$database;NAME DBID LOG_MODE OPEN_MODE---------------------------------------------------DB11 1400765095 ARCHIVELOG READ WRITE
启动到mount状态
SQL> shutdown immediate;Database closed.Database dismounted.ORACLE instance shut down.SQL> startup mountORACLE instance started.TotalSystemGlobalArea835104768 bytesFixedSize2257840 bytesVariableSize507513936 bytesDatabaseBuffers322961408 bytesRedoBuffers2371584 bytesDatabase mounted.SQL>exitDisconnectedfromOracleDatabase11gEnterpriseEditionRelease11.2.0.4.0-64bitProductionWith the Partitioning, OLAP,DataMiningandRealApplicationTesting options
执行命令
db11@oracle /home/ora11g$ nid target=sys/oracle dbname=newdb11 setname=yesDBNEWID:Release11.2.0.4.0-Production on MonMar3007:44:262015Copyright(c)1982,2011,Oracleand/or its affiliates.All rights reserved.Connected to database DB11 (DBID=1400765095)Connected to server version 11.2.0ControlFilesin database:/u01/app/oracle11g/oradata/DB11/controlfile/o1_mf_bcc2h7dx_.ctlChange database name of database DB11 to NEWDB11?(Y/[N])=> YProceedingwith operationChanging database name from DB11 to NEWDB11ControlFile/u01/app/oracle11g/oradata/DB11/controlfile/o1_mf_bcc2h7dx_.ctl - modifiedDatafile/u01/app/oracle11g/oradata/DB11/datafile/o1_mf_system_bcc2dp1d_.db - wrote new nameDatafile/u01/app/oracle11g/oradata/DB11/datafile/o1_mf_sysaux_bcc2dp2c_.db - wrote new nameDatafile/u01/app/oracle11g/oradata/DB11/datafile/fdstore.db - wrote new nameDatafile/u01/app/oracle11g/oradata/DB11/datafile/o1_mf_users_bcc2dp33_.db - wrote new nameDatafile/u01/app/oracle11g/oradata/DB11/datafile/o1_mf_new_user_bcp23qgn_.db - wrote new nameDatafile/u01/app/oracle11g/oradata/DB11/datafile/undotbs2.db - wrote new nameDatafile/u01/app/oracle11g/oradata/DB11/datafile/o1_mf_temp_bcc2hld2_.tm - wrote new nameControlFile/u01/app/oracle11g/oradata/DB11/controlfile/o1_mf_bcc2h7dx_.ctl - wrote new nameInstance shut downDatabase name changed to NEWDB11.Modify parameter file and generate a new password file before restarting.Succesfully changed database name.DBNEWID -Completed succesfully.
数据库中修改db_name
db11@oracle /u01/app/oracle11g/product/11.2.0/dbhome_1/dbs$ sqlplus /as sysdbaSQL*Plus:Release11.2.0.4.0Production on MonMar3007:58:332015Copyright(c)1982,2013,Oracle.All rights reserved.Connected to an idle instance.SQL> startup nomountORACLE instance started.TotalSystemGlobalArea835104768 bytesFixedSize2257840 bytesVariableSize507513936 bytesDatabaseBuffers322961408 bytesRedoBuffers2371584 bytesSQL>set line 200SQL> show parameter db_nameSQL> show parameter db_nameNAME TYPE VALUE----------------------------------------------------------------------------------------db_name string db11SQL> alter system set db_name=newdb11 scope=spfile;System altered.SQL> startup mount forceORACLE instance started.TotalSystemGlobalArea835104768 bytesFixedSize2257840 bytesVariableSize507513936 bytesDatabaseBuffers322961408 bytesRedoBuffers2371584 bytesDatabase mounted.SQL>exitDisconnectedfromOracleDatabase11gEnterpriseEditionRelease11.2.0.4.0-64bitProductionWith the Partitioning, OLAP,DataMiningandRealApplicationTesting options
创建新的密码文件
db11@oracle /home/ora11g$db11@oracle /home/ora11g$ orapwd file=$ORACLE_HOME/dbs/orapwnewdb11 password=oracle entries=10创建参数文件db11@oracle /home/ora11g$ export ORACLE_SID=newdb11SQL> create spfile from pfile;File created.SQL>exitDisconnectedfromOracleDatabase11gEnterpriseEditionRelease11.2.0.4.0-64bitProductionWith the Partitioning, OLAP,DataMiningandRealApplicationTesting options根据原参数文件,修改成新的参数文件,具体操作略
启动新的数据库名的数据库
newdb11@oracle /home/ora11g$ export ORACLE_SID=newdb11newdb11@oracle /home/ora11g$ sqlplus /as sysdbaSQL*Plus:Release11.2.0.4.0Production on MonMar3008:16:162015Copyright(c)1982,2013,Oracle.All rights reserved.Connected to:OracleDatabase11gEnterpriseEditionRelease11.2.0.4.0-64bitProductionWith the Partitioning, OLAP,DataMiningandRealApplicationTesting optionsSQL> startupORACLE instance started.TotalSystemGlobalArea835104768 bytesFixedSize2257840 bytesVariableSize507513936 bytesDatabaseBuffers322961408 bytesRedoBuffers2371584 bytesDatabase mounted.Database opened.SQL>SQL>select instance_name,status from v$instance;INSTANCE_NAME STATUS----------------------------newdb11 OPEN
OK。。。启动成功