oracle更改例項名

安佰勝發表於2011-04-18

oracle更改例項名
------------------
--環境情況
SQL> select * from v$version;
BANNER
----------------------------------------------------------------
Oracle9i Enterprise Edition Release 9.2.0.6.0 - 64bit Production
PL/SQL Release 9.2.0.6.0 - Production
CORE    9.2.0.6.0       Production
TNS for Solaris: Version 9.2.0.6.0 - Production
NLSRTL Version 9.2.0.6.0 - Production
SQL> select instance_name from v$instance;
INSTANCE_NAME
----------------
MED
SQL> select name from v$database;
NAME
---------
MED
--關閉資料塊
SQL> SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.

--修改環境變數ORACLE_SID
vi .bash_profile
將ORACLE_SID=MED改為ORACLE_SID=KONG
--修改口令檔案和引數檔案
oracle@V480-2 /opt/oracle/product/9.2.0$cd dbs/
oracle@V480-2 /opt/oracle/product/9.2.0/dbs$ls
init.ora       initMED.ora    initdw.ora     lkMED          orapwMED       snapcf_MED.f   spfileMED.ora
oracle@V480-2 /opt/oracle/product/9.2.0/dbs$mv orapwMED orapwKONG
oracle@V480-2 /opt/oracle/product/9.2.0/dbs$mv spfileMED.ora spfileKONG.ora
oracle@V480-2 /opt/oracle/product/9.2.0/dbs$mv initMED.ora initKONG.ora
oracle@V480-2 /opt/oracle/product/9.2.0/dbs$ls
init.ora        initKONG.ora    initdw.ora      lkMED           orapwKONG       snapcf_MED.f    spfileKONG.ora
--重新登入oracle使用者使環境變數生效
oracle@V480-2 /opt/oracle/product/9.2.0/dbs$exit
logout
root@V480-2 ~#su - oracle
--啟動資料塊
SQL> startup
ORACLE instance started.
Total System Global Area 2585237200 bytes
Fixed Size                   734928 bytes
Variable Size             436207616 bytes
Database Buffers         2147483648 bytes
Redo Buffers                 811008 bytes
Database mounted.
Database opened.
--驗證
SQL> select instance_name from v$instance;
INSTANCE_NAME
----------------
KONG
SQL> select name from v$database;
NAME
---------
MED
----------------------
--結論
通過修改環境變數中ORACLE_SID以及對應的引數檔名和口令檔名就可以重新命名例項
dump檔案對應的目錄如果也要改的話需要先更改引數檔案中dump的路徑
即使修改了例項名資料塊名也不會發生變化

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/13177610/viewspace-692775/,如需轉載,請註明出處,否則將追究法律責任。

相關文章