首頁 資料庫 mysql教程 oracle工具之nid命令的使用

oracle工具之nid命令的使用

Jun 07, 2016 pm 05:37 PM
database oracle 使用者名稱 連接資料庫

当我们手动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” 博客,请务必保留此出处

本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn

熱AI工具

Undresser.AI Undress

Undresser.AI Undress

人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover

AI Clothes Remover

用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool

Undress AI Tool

免費脫衣圖片

Clothoff.io

Clothoff.io

AI脫衣器

Video Face Swap

Video Face Swap

使用我們完全免費的人工智慧換臉工具,輕鬆在任何影片中換臉!

熱門文章

<🎜>:泡泡膠模擬器無窮大 - 如何獲取和使用皇家鑰匙
3 週前 By 尊渡假赌尊渡假赌尊渡假赌
北端:融合系統,解釋
4 週前 By 尊渡假赌尊渡假赌尊渡假赌
Mandragora:巫婆樹的耳語 - 如何解鎖抓鉤
3 週前 By 尊渡假赌尊渡假赌尊渡假赌

熱工具

記事本++7.3.1

記事本++7.3.1

好用且免費的程式碼編輯器

SublimeText3漢化版

SublimeText3漢化版

中文版,非常好用

禪工作室 13.0.1

禪工作室 13.0.1

強大的PHP整合開發環境

Dreamweaver CS6

Dreamweaver CS6

視覺化網頁開發工具

SublimeText3 Mac版

SublimeText3 Mac版

神級程式碼編輯軟體(SublimeText3)

熱門話題

Java教學
1670
14
CakePHP 教程
1428
52
Laravel 教程
1329
25
PHP教程
1274
29
C# 教程
1256
24
oracle打不開怎麼辦 oracle打不開怎麼辦 Apr 11, 2025 pm 10:06 PM

Oracle 打不開的解決辦法包括:1. 啟動數據庫服務;2. 啟動監聽器;3. 檢查端口衝突;4. 正確設置環境變量;5. 確保防火牆或防病毒軟件未阻止連接;6. 檢查服務器是否已關閉;7. 使用 RMAN 恢復損壞的文件;8. 檢查 TNS 服務名稱是否正確;9. 檢查網絡連接;10. 重新安裝 Oracle 軟件。

oracle游標關閉怎麼解決 oracle游標關閉怎麼解決 Apr 11, 2025 pm 10:18 PM

解決 Oracle 游標關閉問題的方法包括:使用 CLOSE 語句顯式關閉游標。在 FOR UPDATE 子句中聲明游標,使其在作用域結束後自動關閉。在 USING 子句中聲明游標,使其在關聯的 PL/SQL 變量關閉時自動關閉。使用異常處理確保在任何異常情況下關閉游標。使用連接池自動關閉游標。禁用自動提交,延遲游標關閉。

oracle怎麼循環創建游標 oracle怎麼循環創建游標 Apr 12, 2025 am 06:18 AM

Oracle 中,FOR LOOP 循環可動態創建游標, 步驟為:1. 定義游標類型;2. 創建循環;3. 動態創建游標;4. 執行游標;5. 關閉游標。示例:可循環創建游標,顯示前 10 名員工姓名和工資。

oracle視圖怎麼導出 oracle視圖怎麼導出 Apr 12, 2025 am 06:15 AM

可以通過 EXP 實用程序導出 Oracle 視圖:登錄 Oracle 數據庫。啟動 EXP 實用程序,指定視圖名稱和導出目錄。輸入導出參數,包括目標模式、文件格式和表空間。開始導出。使用 impdp 實用程序驗證導出。

oracle日誌寫滿怎麼辦 oracle日誌寫滿怎麼辦 Apr 12, 2025 am 06:09 AM

Oracle 日誌文件寫滿時,可採用以下解決方案:1)清理舊日誌文件;2)增加日誌文件大小;3)增加日誌文件組;4)設置自動日誌管理;5)重新初始化數據庫。在實施任何解決方案前,建議備份數據庫以防數據丟失。

甲骨文在商業世界中的作用 甲骨文在商業世界中的作用 Apr 23, 2025 am 12:01 AM

Oracle不僅是數據庫公司,還是雲計算和ERP系統的領導者。 1.Oracle提供從數據庫到雲服務和ERP系統的全面解決方案。 2.OracleCloud挑戰AWS和Azure,提供IaaS、PaaS和SaaS服務。 3.Oracle的ERP系統如E-BusinessSuite和FusionApplications幫助企業優化運營。

HDFS配置CentOS需要哪些步驟 HDFS配置CentOS需要哪些步驟 Apr 14, 2025 pm 06:42 PM

在CentOS系統上搭建Hadoop分佈式文件系統(HDFS)需要多個步驟,本文提供一個簡要的配置指南。一、前期準備安裝JDK:在所有節點上安裝JavaDevelopmentKit(JDK),版本需與Hadoop兼容。可從Oracle官網下載安裝包。環境變量配置:編輯/etc/profile文件,設置Java和Hadoop的環境變量,使系統能夠找到JDK和Hadoop的安裝路徑。二、安全配置:SSH免密登錄生成SSH密鑰:在每個節點上使用ssh-keygen命令

oracle數據庫怎麼停止 oracle數據庫怎麼停止 Apr 12, 2025 am 06:12 AM

要停止 Oracle 數據庫,請執行以下步驟:1. 連接到數據庫;2. 優雅關機數據庫(shutdown immediate);3. 完全關機數據庫(shutdown abort)。

See all articles