这篇文章主要介绍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”这篇文章的所有内容,感谢各位的阅读!希望分享的内容对大家有帮助,更多相关知识,欢迎关注创新互联行业资讯频道!
当前标题:ORACLE中在不删库的情况下如何直接修改数据库dbname
转载来于:http://scpingwu.com/article/iedijo.html