Chinaunix首页 | 论坛 | 博客
  • 博客访问: 218136
  • 博文数量: 57
  • 博客积分: 1376
  • 博客等级: 中尉
  • 技术积分: 658
  • 用 户 组: 普通用户
  • 注册时间: 2010-05-09 09:51
文章分类

全部博文(57)

文章存档

2012年(1)

2011年(56)

分类: Oracle

2011-03-19 21:07:46

1. Change the current dbname from beijng to test:
SQL> show parameter name

db_file_name_convert               string
db_name                                      string      beijing
db_unique_name                       string      beijing
global_names                              boolean     FALSE
instance_name                             string      test
lock_name_space                        string
log_file_name_convert               string
service_names                             string      beijing


2. nid usage:
[oracle@milo dbs]$ nid

DBNEWID: Release 10.2.0.1.0 - Production on Sat Mar 19 20:56:15 2011

Copyright (c) 1982, 2005, Oracle.  All rights reserved.

Keyword     Description                    (Default)
----------------------------------------------------
TARGET      Username/Password              (NONE)
DBNAME      New database name              (NONE)
LOGFILE     Output Log                     (NONE)
REVERT      Revert failed change           NO
SETNAME     Set a new database name only   NO
APPEND      Append to output log           NO
HELP        Displays these messages        NO



3. Shutdown the database and mount the database:
SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup mount;
ORACLE instance started.

Total System Global Area  293601280 bytes
Fixed Size                  1219016 bytes
Variable Size             234882616 bytes
Database Buffers           50331648 bytes
Redo Buffers                7168000 bytes
Database mounted.


4. Using nid to change the db_name

[oracle@milo dbs]$ nid target=sys/oracle dbname=test

DBNEWID: Release 10.2.0.1.0 - Production on Sat Mar 19 21:03:30 2011

Copyright (c) 1982, 2005, Oracle.  All rights reserved.

Connected to database BEIJING (DBID=3487842441)

Connected to server version 10.2.0

Control Files in database:
    /u01/app/oracle/oradata/test/control01.ctl

Change database ID and database name BEIJING to TEST? (Y/[N]) =>
y

Proceeding with operation
Changing database ID from 3487842441 to 2044366754
Changing database name from BEIJING to TEST
    Control File /u01/app/oracle/oradata/test/control01.ctl - modified
    Datafile /u01/app/oracle/oradata/test/system01.dbf - dbid changed, wrote new name
    Datafile /u01/app/oracle/oradata/test/undotbs01.dbf - dbid changed, wrote new name
    Datafile /u01/app/oracle/oradata/test/sysaux01.dbf - dbid changed, wrote new name
    Datafile /u01/app/oracle/oradata/test/users01.dbf - dbid changed, wrote new name
    Datafile /u01/app/oracle/oradata/test/yy01.dbf - dbid changed, wrote new name
    Datafile /u01/app/oracle/oradata/test/qq.dbf - dbid changed, wrote new name
    Datafile /bk/temp01.dbf - dbid changed, wrote new name
    Control File /u01/app/oracle/oradata/test/control01.ctl - dbid changed, wrote new name
    Instance shut down

Database name changed to TEST.
Modify parameter file and generate a new password file before restarting.
Database ID for database TEST changed to 2044366754.
All previous backups and archived redo logs for this database are unusable.
Database is not aware of previous backups and archived logs in Recovery Area.
Database has been shutdown, open database with RESETLOGS option.
Succesfully changed database name and ID.
DBNEWID - Completed succesfully.



5. Modify your db_name and open your database with resetlogs mode:
[oracle@milo dbs]$ export ORACLE_SID=test
[oracle@milo dbs]$ vim inittest.ora
[oracle@milo dbs]$ grep db_name inittest.ora
db_name  = 'test'
[oracle@milo dbs]$ sqlplus / as sysdba

SQL*Plus: Release 10.2.0.1.0 - Production on Sat Mar 19 21:06:14 2011

Copyright (c) 1982, 2005, Oracle.  All rights reserved.

Connected to an idle instance.

SQL> startup
ORACLE instance started.

Total System Global Area  293601280 bytes
Fixed Size                  1219016 bytes
Variable Size             234882616 bytes
Database Buffers           50331648 bytes
Redo Buffers                7168000 bytes
Database mounted.
ORA-01589: must use RESETLOGS or NORESETLOGS option for database open


SQL> alter database open resetlogs;

Database altered.


SQL> show parameter name

NAME                                              TYPE        VALUE
------------------------------------ ----------- ------------------------------
db_file_name_convert                  string
db_name                                         string         test
db_unique_name                          string         test
global_names                                boolean     FALSE
instance_name                               string         test
lock_name_space                          string
log_file_name_convert                 string
service_names                               string         test



阅读(1679) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~