您的位置:首页 > 数据库 > Oracle

ORACLE 使用nid修改数据库名称

2017-06-12 13:39 337 查看
1.数据库当前设置:

SQL> select * from v$version;

BANNER

--------------------------------------------------------------------------------

Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production

PL/SQL Release 11.2.0.4.0 - Production

CORE    11.2.0.4.0      Production

TNS for Linux: Version 11.2.0.4.0 - Production

NLSRTL Version 11.2.0.4.0 - Production

SQL> 

------------------------------------------------------------------------------------------

SQL> show parameter name

NAME                                 TYPE        VALUE

------------------------------------ ----------- ------------------------------

cell_offloadgroup_name               string

db_file_name_convert                 string

db_name                              string      prdhtjc

db_unique_name                       string      prdhtjc

global_names                         boolean     FALSE

instance_name                        string      prdhtjc

lock_name_space                      string

log_file_name_convert                string

processor_group_name                 string

service_names                        string      prdhtjc

SQL> 

------------------------------------------------------------------------------------------

2.Shutdown数据库:

SQL> shutdown immediate

Database closed.

Database dismounted.

ORACLE instance shut down.

------------------------------------------------------------------------------------------

3.Startup mount :

SQL> startup mount

ORACLE instance started.

Total System Global Area  196681728 bytes

Fixed Size                       1343864 bytes

Variable Size                    88084104 bytes

Database Buffers             104857600 bytes

Redo Buffers                   2396160 bytes

Database mounted.

------------------------------------------------------------------------------------------

4. 使用NID更改:

SQL> host

nid target=sys/oracle@prdhtjc dbname=htjc01

oracle@prdhtjc1:/backup/rmanbackdir$nid target=sys/oracle@prdhtjc dbname=htjc01

DBNEWID: Release 11.2.0.4.0 - Production on Sun Jan 12 13:41:28 2014

Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.

Connected to database PRDHTJC (DBID=4253573492)

Connected to server version 11.2.0

Control Files in database:

    /dbfile/oradata/prdhtjc/control01.ctl

    /dbfile/oradata/prdhtjc/control02.ctl

    /dbfile/oradata/prdhtjc/control03.ctl

Change database ID and database name PRDHTJC to HTJC01? (Y/
) => Y

Proceeding with operation

Changing database ID from 4253573492 to 1038336969

Changing database name from PRDHTJC to HTJC01

    Control File /dbfile/oradata/prdhtjc/control01.ctl - modified

    Control File /dbfile/oradata/prdhtjc/control02.ctl - modified

    Control File /dbfile/oradata/prdhtjc/control03.ctl - modified

    Datafile /dbfile/oradata/prdhtjc/system01.db - dbid changed, wrote new name

    Datafile /dbfile/oradata/prdhtjc/sysaux01.db - dbid changed, wrote new name

    Datafile /dbfile/oradata/prdhtjc/undotbs01.db - dbid changed, wrote new name

    Datafile /dbfile/oradata/prdhtjc/users01.db - dbid changed, wrote new name

    Datafile /dbfile/oradata/prdhtjc/htjc01.db - dbid changed, wrote new name

    Datafile /dbfile/oradata/prdhtjc/htjc02.db - dbid changed, wrote new name

    Datafile /dbfile/oradata/prdhtjc/htjc03.db - dbid changed, wrote new name

    Datafile /dbfile/oradata/prdhtjc/htjc04.db - dbid changed, wrote new name

    Datafile /dbfile/oradata/prdhtjc/htjc05.db - dbid changed, wrote new name

    Datafile /dbfile/oradata/prdhtjc/htjc06.db - dbid changed, wrote new name

    Datafile /dbfile/oradata/prdhtjc/htjc07.db - dbid changed, wrote new name

    Datafile /dbfile/oradata/prdhtjc/htjc08.db - dbid changed, wrote new name

    Datafile /dbfile/oradata/prdhtjc/htjc09.db - dbid changed, wrote new name

    Datafile /dbfile/oradata/prdhtjc/htjc10.db - dbid changed, wrote new name

    Datafile /dbfile/oradata/prdhtjc/zuhe01.db - dbid changed, wrote new name

    Datafile /dbfile/oradata/prdhtjc/ptrd01.db - dbid changed, wrote new name

    Datafile /dbfile/oradata/prdhtjc/ptrd02.db - dbid changed, wrote new name

    Datafile /dbfile/oradata/prdhtjc/temp01.db - dbid changed
aced
, wrote new name

    Control File /dbfile/oradata/prdhtjc/control01.ctl - dbid changed, wrote new name

    Control File /dbfile/oradata/prdhtjc/control02.ctl - dbid changed, wrote new name

    Control File /dbfile/oradata/prdhtjc/control03.ctl - dbid changed, wrote new name

    Instance shut down

Database name changed to HTJC01.

Modify parameter file and generate a new password file before restarting.

Database ID for database HTJC01 changed to 1038336969.

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.Shutdown database:

SQL> shutdown immediate

ORA-01109: database not open

Database dismounted.

ORACLE instance shut down.

------------------------------------------------------------------------------------------

6.修改初始化参数文件、spfile文件(init.ora/spfile):

instance_name=newchen

#instance_name=chen

db_domain=""

db_name=newchen

#db_name=chen

------------------------------------------------------------------------------------------

7.Startup mount,resetlogs打开:

[oracle@localhost dbs]$ export ORACLE_SID=htjc01

[oracle@localhost dbs]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.3.0 Production on 2 04:59:39 2012

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

Connected to an idle instance.

SQL> startup mount

ORACLE instance started.

Total System Global Area  196681728 bytes

Fixed Size                  1343864 bytes

Variable Size              83889800 bytes

Database Buffers          109051904 bytes

Redo Buffers                2396160 bytes

Database mounted.

------------------------------------------------------------------------------------------

Step8、修改数据库相关文件的路径名称:

select name from V$datafile;

select member from V$logfile;

select name from V$tempfile;

For exp:

alter database rename file '...' to '...';

SQL> alter database open resetlogs;

Database altered.

SQL> show parameter name

NAME                                 TYPE                   VALUE

------------------------------------ ---------------------- ------------------------------

db_file_name_convert             string

db_name                               string                 newchen

db_unique_name                    string                 newchen

global_names                         boolean                FALSE

instance_name                       string                 newchen

lock_name_space                    string

log_file_name_convert             string

processor_group_name            string

service_names                        string                 newchen
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: