oracle工具之nid命令的使用

当我们手动copy了整个数据库,并通过重建控制文件给数据库指定了新的dbname,但是却不能给数据库分配新的dbid.对于以上问题我们可以通过nid命令来对数据库分配一

   当我们手动copy了整个数据库,并通过重建控制文件给数据库指定了新的dbname,但是却不能给数据库分配新的dbid.对于以上问题我们可以通过nid命令来对数据库分配一个全新的dbid。同时需要注意rman也是通过dbid来区分数据库。

一 命令解释

[oracle@source ~]$ nid  help=yes

DBNEWID: Release 11.2.0.2.0 – Production on Thu Dec 5 00:09:50 2013

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

Keyword     Description                    (Default)

—————————————————-

TARGET      Username/Password              (NONE)    指定连接数据库用户名和密码

DBNAME      New database name              (NONE)  DBNAME=new_db_name 改变数据库的名字  

LOGFILE     Output Log                     (NONE) LOGFILE=logfile指定输出消息到指定的日志文件,默认nid覆盖之前的日子文件

REVERT      Revert failed change           NO  指定yes表明更改dbid失败时能够恢复之前的状态

SETNAME     Set a new database name only   NO  指定yes表明仅仅更改数据库db_name

APPEND      Append to output log           NO  指定yes标识输出追加到已经存在的日志文件

HELP        Displays these messages        NO  指定yes显示帮助信息

注意:可以同时更改数据库的dbid和db_name,也可以仅改变数据库的db_name、抑或仅更改数据库的dbid。语法分别如下:

改变dbid和db_name : nid target=sys/dhhzdhhz  dbname=crm_test (也可以target=/)

仅改变db_name:  nid target=sys/dhhzdhhz dbname=crm_test  setname=yes (也可以target=/)

仅更改dbid: nid target=sys/dhhzdhhz (也可以target=/)

二 使用nid的注意事项

1 确保有能够对数据库进行完全恢复的备份。

2 确保执行更改dbid操作时数据库处于mounted状态且mounted之前数据库是经过shutdown immediate关闭的。

3 使用nid更改数据库的dbid后,数据库需要alter database open resetlogs启动,启动之后须对数据库进行一次全备份,因为之前的备份和归档已经不能再使用了。

4 使用nid更改数据库dbname后,需更改初始化参数文件中的DB_NAME参数并重建密码文件。

5 使用nid不能更改全局数据库名。

6 确保所有数据文件处于online状态且不需要恢复。

7 尽量确保oracle没有离线的数据文件和只读表空间,如果有使其正常化。

三 举两个例子

eg1:仅更改数据库dbid

SQL> shutdown immediate;

Database closed.

Database dismounted.

ORACLE instance shut down.

SQL> startup mount;

ORACLE instance started.

Total System Global Area 1252663296 bytes

Fixed Size                  2226072 bytes

Variable Size             922749032 bytes

Database Buffers          318767104 bytes

Redo Buffers                8921088 bytes

Database mounted.

SQL> exit

Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 – 64bit Production

With the Partitioning, OLAP, Data Mining and Real Application Testing options

[oracle@source ~]$ nid target=sys

DBNEWID: Release 11.2.0.2.0 – Production on Wed Dec 4 23:39:11 2013

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

Password:

Connected to database CRM (DBID=3599153036)

Connected to server version 11.2.0

Control Files in database:

   /oracle/CRM/control03.ctl

Change database ID of database CRM? (Y/[N]) => y

Proceeding with operation

Changing database ID from 3599153036 to 3641774948

   Control File /oracle/CRM/control03.ctl – modified

   Datafile /oracle/CRM/system01.db – dbid changed

   Datafile /oracle/CRM/sysaux01.db – dbid changed

   Datafile /oracle/CRM/zx.db – dbid changed

   Datafile /oracle/CRM/users01.db – dbid changed

   Datafile /oracle/CRM/pos.db – dbid changed

   Datafile /oracle/CRM/erp.db – dbid changed

   Datafile /oracle/CRM/user01.db – dbid changed

   Datafile /oracle/CRM/undotbs03.db – dbid changed

   Datafile /oracle/CRM/crm.db – dbid changed

   Datafile /oracle/CRM/jxc.db – dbid changed

   Datafile /oracle/CRM/temp01.db – dbid changed

   Control File /oracle/CRM/control03.ctl – dbid changed

   Instance shut down

Database ID for database CRM changed to 3641774948.

All previous backups and archived redo logs for this database are unusable.

Database has been shutdown, open database with RESETLOGS option.

Succesfully changed database ID.

DBNEWID – Completed succesfully.

[oracle@source ~]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.2.0 Production on Wed Dec 4 23:47:21 2013

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

Connected to an idle instance.

SQL> startup  mount;

ORACLE instance started.

Total System Global Area 1252663296 bytes

Fixed Size                  2226072 bytes

Variable Size             922749032 bytes

Database Buffers          318767104 bytes

Redo Buffers                8921088 bytes

Database mounted.

SQL> alter database open resetlogs;

Database altered.

SQL> select dbid,name from v$database;

     DBID NAME

———- ———

3641774948 CRM

eg2 :仅更改数据库db_name

oracle@source ~]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.2.0 Production on Thu Dec 5 00:11:03 2013

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

Connected to:

Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 – 64bit Production

With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> select open_mode from v$database;

OPEN_MODE

——————–

READ WRITE

SQL> shutdown immediate;

Database closed.

Database dismounted.

ORACLE instance shut down.

SQL> startup mount;

ORACLE instance started.

Total System Global Area 1252663296 bytes

Fixed Size                  2226072 bytes

Variable Size             905971816 bytes

Database Buffers          335544320 bytes

Redo Buffers                8921088 bytes

Database mounted.

SQL> exit

Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 – 64bit Production

With the Partitioning, OLAP, Data Mining and Real Application Testing options

oracle@source ~]$ nid target=sys dbname=CRM_TEST setname=YES

DBNEWID: Release 11.2.0.2.0 – Production on Thu Dec 5 00:24:58 2013

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

Password:

Connected to database CRM (DBID=3641774948)

Connected to server version 11.2.0

Control Files in database:

   /oracle/CRM/control03.ctl

Change database name of database CRM to CRM_TEST? (Y/[N]) => y

Proceeding with operation

Changing database name from CRM to CRM_TEST

   Control File /oracle/CRM/control03.ctl – modified

   Datafile /oracle/CRM/system01.db – wrote new name

   Datafile /oracle/CRM/sysaux01.db – wrote new name

   Datafile /oracle/CRM/zx.db – wrote new name

   Datafile /oracle/CRM/users01.db – wrote new name

   Datafile /oracle/CRM/pos.db – wrote new name

   Datafile /oracle/CRM/erp.db – wrote new name

   Datafile /oracle/CRM/user01.db – wrote new name

   Datafile /oracle/CRM/undotbs03.db – wrote new name

   Datafile /oracle/CRM/crm.db – wrote new name

   Datafile /oracle/CRM/jxc.db – wrote new name

   Datafile /oracle/CRM/temp01.db – wrote new name

   Control File /oracle/CRM/control03.ctl – wrote new name

   Instance shut down

Database name changed to CRM_TEST.

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

Succesfully changed database name.

DBNEWID – Completed succesfully.

[oracle@source ~]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.2.0 Production on Thu Dec 5 00:25:33 2013

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

Connected to an idle instance.

SQL> startup nomount;

ORACLE instance started.

Total System Global Area 1252663296 bytes

Fixed Size                  2226072 bytes

Variable Size             905971816 bytes

Database Buffers          335544320 bytes

Redo Buffers                8921088 bytes

SQL> alter system set db_name=CRM_TEST scope=spfile;

System altered.

[oracle@source ~]$orapwd file=”$ORACLE_HOME/dbs/orapw$ORACLE_SID” password=dhhzdhhz force=y

[oracle@source dbs]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.2.0 Production on Thu Dec 5 00:34:40 2013

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

Connected to:

Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 – 64bit Production

With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> startup force open;

ORACLE instance started.

Total System Global Area 1252663296 bytes

Fixed Size                  2226072 bytes

Variable Size             905971816 bytes

Database Buffers          335544320 bytes

Redo Buffers                8921088 bytes

Database mounted.

Database opened.

SQL> select dbid,name from v$database;

     DBID NAME

———- ———

3641774948 CRM_TEST

本文出自 “myblog” 博客,请务必保留此出处

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至253000106@qq.com举报,一经查实,本站将立刻删除。

发布者:PHP中文网,转转请注明出处:https://www.chuangxiangniao.com/p/1865061.html

(0)
上一篇 2025年2月22日 07:04:54
下一篇 2025年2月22日 07:05:23

AD推荐 黄金广告位招租... 更多推荐

相关推荐

  • navicat的连接信息保存在哪

    Navicat连接信息保存在.ncc文件中,包括以下信息:数据库类型主机名或IP地址端口号用户名密码连接参数 Navicat的连接信息保存在哪里? Navicat的连接信息保存在以下位置: Windows: %APPDATA%Premium…

    2025年2月23日
    100
  • navicat如何配置连接oracle

    要使用 Navicat 连接 Oracle 数据库,请依次执行以下步骤:1. 创建新连接(连接类型为 Oracle);2. 配置连接参数(包括主机名/IP、端口、服务名、用户名、密码);3. 启用高级选项(可选);4. 测试连接;5. 保存…

    2025年2月23日
    100
  • navicat怎么新建

    使用 Navicat 创建数据库:连接到数据库服务器。右键单击“数据库”节点,选择“新建数据库”。输入数据库名称、字符集、排序规则。设置数据库属性(可选)。单击“保存”。 如何使用 Navicat 创建一个新数据库 Navicat 是一款强…

    2025年2月23日
    100
  • navicat干嘛的

    Navicat 是一款数据库管理软件,具备以下主要功能:连接各种数据库系统(如 MySQL、PostgreSQL)轻松管理数据(浏览、编辑、添加、删除、排序)管理数据库结构(创建、修改和删除表、索引等)提供查询生成器,简化 SQL 查询支持…

    2025年2月23日
    100
  • navicat软件有哪些

    Navicat 是一款数据库管理工具,专为多个主流数据库而设计,提供了一系列功能,包括数据库连接、SQL 编辑、数据建模、导入/导出、代码生成、版本控制、备份/还原,以及分析/性能优化,适用于广大需要管理数据库的用户,如 DBA、开发人员、…

    2025年2月23日
    100
  • navicat数据库文件在哪

    Navicat 数据库配置文件的存储位置因操作系统而异:Windows:用户特定路径为 %APPDATA%PremiumSoftNavicatmacOS:用户特定路径为 ~/Library/Application Support/Navic…

    2025年2月23日
    100
  • navicat怎么打开数据库文件

    要使用 Navicat 打开数据库文件,请连接到数据库服务器,然后右键单击要打开的文件并选择“打开”。 Navicat 打开数据库文件的方法 要使用 Navicat 打开数据库文件,请按照以下步骤操作: 步骤 1:连接到数据库服务器 启动 …

    2025年2月23日
    100
  • navicat怎么查看数据库所在文件夹

    在Navicat中查看数据库所在文件夹,请按照以下步骤操作:1. 在导航树中右键单击目标数据库;2. 选择“属性”;3. 在“常规”选项卡中查找“文件位置”字段。对于MySQL数据库,文件位置为.frm文件的文件夹;对于其他类型的数据库,文…

    2025年2月23日
    100
  • 怎么用navicat导入外部数据库

    使用 Navicat 导入外部数据库的步骤:连接到目标数据库。选择“工具”菜单中的“导入向导”。选择数据源类型,如 Microsoft SQL Server、Oracle 或 MySQL。输入数据源参数,包括主机、端口、用户名和密码。预览数…

    2025年2月23日
    100
  • navicat中如何导出数据库

    使用 Navicat 导出数据库分步指南:连接到数据库。选择要导出的数据库。选择导出格式和范围。配置导出设置(可选)。选择导出路径。开始导出。完成导出并查找导出文件。 如何使用 Navicat 导出数据库 Navicat 是一款功能强大的数…

    2025年2月23日
    100

发表回复

登录后才能评论