如何修改数据库的db_name?下面提供一种方法供参考
本例将db_name=testdb改名成db_name=testdb1,修改结束后,instance_name还不变,仍为testdb
首先将数据库启动到mount状态
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL>
SQL>
SQL> startup mount
ORACLE instance started.
Total System Global Area 289406976 bytes
Fixed Size 1219040 bytes
Variable Size 109053472 bytes
Database Buffers 176160768 bytes
Redo Buffers 2973696 bytes
Database mounted.
然后使用命令nid target=sys/gaokai@testdb dbname=testdb1修改数据库的db_name
oracle:/opt/ora10g/product/10.2.0/db_1/dbs#]nid target=sys/gaokai@testdb dbname=testdb1
DBNEWID: Release 10.2.0.1.0 - Production on 星期三 6月 23 02:29:39 2010
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Connected to database TESTDB (DBID=2502365763)
Connected to server version 10.2.0
Control Files in database:
/home/oracle/oradata/testdb/control01.ctl
/home/oracle/testdb/controlfile/control02.ctl
/home/oracle/oradata/testdb/control03.ctl
Change database ID and database name TESTDB to TESTDB1? (Y/[N]) => Y
Proceeding with operation
Changing database ID from 2502365763 to 474489427
Changing database name from TESTDB to TESTDB1
.........
Succesfully changed database name and ID.
DBNEWID - Completed succesfully.
然后修改系统的环境变量中的SID,以及修改数据库的pfile文件中的配置.
再启动数据库:
SQL> select instance_name from v$instance;
INSTANCE_NAME
--------------------------------
testdb
SQL> select dbid,name from v$database;
DBID NAME
---------- ------------------
474489427 TESTDB1
oracle进程情况:
[oracle:/home/oracle#]ps -fu oracle
UID PID PPID C STIME TTY TIME CMD
oracle 19314 1 0 Jun20 ? 00:00:04 /opt/ora10g/product/10.2.0/db_1/bin/tnslsnr LISTENER -inherit
oracle 24890 24889 0 00:49 pts/2 00:00:00 -bash
oracle 24989 24988 0 00:54 pts/1 00:00:00 -bash
oracle 25056 24989 0 01:03 pts/1 00:00:00 sqlplus
oracle 25306 1 0 02:31 ? 00:00:00 ora_pmon_testdb
oracle 25308 1 0 02:31 ? 00:00:00 ora_psp0_testdb
oracle 25310 1 0 02:31 ? 00:00:00 ora_mman_testdb
oracle 25312 1 0 02:31 ? 00:00:00 ora_dbw0_testdb
oracle 25314 1 0 02:31 ? 00:00:00 ora_lgwr_testdb
oracle 25316 1 0 02:31 ? 00:00:00 ora_ckpt_testdb
oracle 25318 1 0 02:31 ? 00:00:01 ora_smon_testdb
oracle 25320 1 0 02:31 ? 00:00:00 ora_reco_testdb
oracle 25322 1 0 02:31 ? 00:00:00 ora_cjq0_testdb
oracle 25324 1 0 02:31 ? 00:00:01 ora_mmon_testdb
oracle 25326 1 0 02:31 ? 00:00:00 ora_mmnl_testdb
oracle 25328 1 0 02:31 ? 00:00:00 ora_d000_testdb
oracle 25330 1 0 02:31 ? 00:00:00 ora_s000_testdb
oracle 25334 1 0 02:32 ? 00:00:00 ora_arc0_testdb
oracle 25336 1 0 02:32 ? 00:00:00 ora_arc1_testdb
oracle 25338 1 0 02:32 ? 00:00:00 ora_arc2_testdb
oracle 25340 1 0 02:32 ? 00:00:00 ora_qmnc_testdb
oracle 25342 1 0 02:32 ? 00:00:00 ora_q000_testdb
oracle 25344 1 0 02:32 ? 00:00:00 ora_q001_testdb
oracle 25356 24890 0 02:36 pts/2 00:00:00 ps -fu oracle
可以看到已经将数据库的db_name修改完成,而没有修改数据库的instance_name.
此试验在oracle 10.2.0.1中测试通过,对于windows平台及其他版本尚未测试.
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/23850820/viewspace-1035462/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/23850820/viewspace-1035462/