您好,登錄后才能下訂單哦!
這篇文章主要介紹ORACLE中在不刪庫的情況下如何直接修改數據庫dbname,文中介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們一定要看完!
環境: Red 6.4 ORACLE:11.2.0.4
原庫dbname:mai
新庫dname:prod
為驗證更改dbname之后數據是否會修改需做以下操作:
原庫: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
這個時候需要退出sqlplus 重新指定ORACLE_SID
[oracle@node1 ~]$ export ORACLE_SID=prod
[oracle@node1 ~]$ sqlplus / as sysdba
將數據庫啟動到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; ##因為沒有使用spfile導致報錯
alter system set db_name=prod scope=spfile
*
ERROR at line 1:
ORA-32001: write to SPFILE requested but no SPFILE is in use
創建spfile
SQL> create spfile from pfile;
File created.
關庫使其使用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.
重啟數據庫
SQL> shu immediate;
ORA-01507: database not mounted
新庫:prod
ORACLE instance shut down.
SQL> startup mount;
ORACLE instance started.
打開數據庫
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
驗證數據是否丟失
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中在不刪庫的情況下如何直接修改數據庫dbname”這篇文章的所有內容,感謝各位的閱讀!希望分享的內容對大家有幫助,更多相關知識,歡迎關注億速云行業資訊頻道!
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。