這篇文章主要介紹ORACLE中在不刪庫的情況下如何直接修改數(shù)據(jù)庫dbname,文中介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們一定要看完!
讓客戶滿意是我們工作的目標(biāo),不斷超越客戶的期望值來自于我們對這個(gè)行業(yè)的熱愛。我們立志把好的技術(shù)通過有效、簡單的方式提供給客戶,將通過不懈努力成為客戶在信息化領(lǐng)域值得信任、有價(jià)值的長期合作伙伴,公司提供的服務(wù)項(xiàng)目有:空間域名、虛擬空間、營銷軟件、網(wǎng)站建設(shè)、迪慶州網(wǎng)站維護(hù)、網(wǎng)站推廣。
環(huán)境: Red 6.4 ORACLE:11.2.0.4
原庫dbname:mai
新庫dname:prod
為驗(yàn)證更改dbname之后數(shù)據(jù)是否會(huì)修改需做以下操作:
原庫:mai
SQL>alter user hr identified by oracle123 account unlock;
SQL> conn hr/oracle
SQL>create table abc (id int,name varchar(20));
SQL>insert into abc (1 'ok',2 'sdad');
SQL> commit;
Commit complete.
SQL> create pfile='initprod.ora' from spfile;
SQL> !nid target=sys/oracle123 dbname=prod logfile=/tmp/change.log
SQL> shu immediate;
ORA-03135: connection lost contact
這個(gè)時(shí)候需要退出sqlplus 重新指定ORACLE_SID
[oracle@node1 ~]$ export ORACLE_SID=prod
[oracle@node1 ~]$ sqlplus / as sysdba
將數(shù)據(jù)庫啟動(dòng)到mount
SQL> startup mount;
ORACLE instance started.
Total System Global Area 4275781632 bytes
Fixed Size 2260088 bytes
Variable Size 1157628808 bytes
Database Buffers 3103784960 bytes
Redo Buffers 12107776 bytes
ORA-01103: database name 'PROD' in control file is not 'MAI'
SQL> alter system set db_name=prod scope=spfile; ##因?yàn)闆]有使用spfile導(dǎo)致報(bào)錯(cuò)
alter system set db_name=prod scope=spfile
*
ERROR at line 1:
ORA-32001: write to SPFILE requested but no SPFILE is in use
創(chuàng)建spfile
SQL> create spfile from pfile;
File created.
關(guān)庫使其使用spfile
SQL> shu immediate;
ORA-01507: database not mounted
ORACLE instance shut down.
SQL> startup mount;
ORACLE instance started.
Total System Global Area 4275781632 bytes
Fixed Size 2260088 bytes
Variable Size 1157628808 bytes
Database Buffers 3103784960 bytes
Redo Buffers 12107776 bytes
ORA-01103: database name 'PROD' in control file is not 'MAI'
修改dbname
SQL> alter system set db_name=prod scope=spfile;
System altered.
重啟數(shù)據(jù)庫
SQL> shu immediate;
ORA-01507: database not mounted
新庫:prod
ORACLE instance shut down.
SQL> startup mount;
ORACLE instance started.
打開數(shù)據(jù)庫
SQL> alter database open resetlogs;
Database altered.
SQL> show parameter name;
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
cell_offloadgroup_name string
db_file_name_convert string
db_name string PROD
db_unique_name string PROD
global_names boolean FALSE
instance_name string prod
lock_name_space string
log_file_name_convert string
processor_group_name string
service_names string PROD
驗(yàn)證數(shù)據(jù)是否丟失
SQL> select USERNAME,ACCOUNT_STATUS from dba_users;
USERNAME ACCOUNT_STATUS
------------------------------ --------------------------------
SYS OPEN
SYSTEM OPEN
HR OPEN
OUTLN EXPIRED & LOCKED
連接hr用戶
SQL> conn hr/oracle
SQL> select * from abc;
ID NAME
---------- --------------------
1 ok
2 sdad
以上是“ORACLE中在不刪庫的情況下如何直接修改數(shù)據(jù)庫dbname”這篇文章的所有內(nèi)容,感謝各位的閱讀!希望分享的內(nèi)容對大家有幫助,更多相關(guān)知識(shí),歡迎關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道!