使用nid命令修改 db name 及 dbid
工作中不可避免地碰到需要修改dbname以及dbid的情形,如将数据库恢复到同一台机器的情形是其中之一。但dbname以及dbid是用于标识
工作中不可避免地碰到需要修改dbname以及dbid的情形,如将数据库恢复到同一台机器的情形是其中之一。但dbname以及dbid是用于标识数据库的重要标志之一,尤其是dbid,具有唯一性,因此对其修改应慎重处理。本文描述了修改dbname以及dbid的步骤并给出示例。
1、修改dbid及dbname的影响
a、修改dbid
等同于创建一个新的数据库,不同的是数据已经存在于数据文件。这是由dbid的唯一性决定的。
修改之后所有之前的备份与归档日志将不可用,因为在恢复时会检测dbid,由于不匹配,则所有备份无效。
修改之后需要使用open resetlogs打开数据库,一个新的incarnation会被创建,且sequence被置为1。
修改之后且成功open的情形下,建议一致性关闭数据库,重启并做一个完整的备份。
b、修改dbname
修改之后,无需使用open resetlogs打开数据库。(注dbname不具有唯一性,global name则具有唯一性)。
修改之后,所有的备份即归档日志依旧可用。
修改之后,,需要修改pfile/spfile中对应的db_name参数以及重建相应的Oracle密码文件。
如果需要使用旧的控制文件恢复数据库,应当使用修改之前的pfile/spfile以及密码文件启动数据库再进行恢复。
c、同时修改dbid及dbname
如果同时修改,则是上述两种情形的综合,修改完毕后需要open resetlogs以及修改pfile/spifle,密码文件,全备数据库。
2、nid命令
robin@SZDB:~> nid
DBNEWID: Release 10.2.0.3.0 - Production on Thu Apr 24 16:34:28 2013
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
在执行nid命令时,该程序会校验当前数据库所有数据文件以及控制文件的头部信息,校验成功后提示是否要修改。
如果使用了输出到日志文件logfile则不会出现修改提示。
接下来nid将使用新的dbid(或者dbname)逐个修改控制文件,数据文件(包括只读文件,正常脱机文件)的头部。
修改成功后自动关闭数据库并退出。
注:对于只读文件,正常脱机文件本文未作测试。其次应确保数据库处于归档状态,可正常归档以及不存在需要recover的数据文件。
3、修改步骤
a、全备数据库,如果是热备(rman or os)应确保所有的归档日志以及联机日志可用
b、删除dbconsole([ID 863800.1]有此要求,如用到dbconsole,应考虑按此操作)
c、启动需要修改的数据库到mount状态(startup mount)
d、如果使用spfile文件启动数据库,备份spfile文件到pfile用于后续修改db_name
e、发布nid命令
nid target=sys/password #此方式是仅仅修改dbid
nid target=/ dbname=new_dbname [setname=yes] # / 表明连接到当前环境的sid,且使用操作系统认证
nid target=sys/password dbname=new_dbname [setname=yes] # setname=yes 仅仅修改数据库名字,如果省略,则两者同时修改
nid target=sys/pwdd@conn_string dbname=new_dbname [setname=yes] #使用连接串连接到远程主机并修改
f、修改Oracle 参数文件 pfile(使用先前从spfile备份的)中的参数db_name,如果仅仅修改dbid,跳过此步骤
g、使用新的参数文件pfile启动到mount状态(如果修改了dbname,如果仅仅是dbid,则直接使用原来的pfile或spfile启动)
h、使用open resetlogs方式打开数据库(修改非dbid,直接打开即可)
i、重建当前数据库的 Oralce 密码文件及将pfile文件转换成spfile文件
j、修改相应的监听器的配值,包括listener.ora以及tnsnames.ora
k、修改全局dbname,如果有用到的话。ALTER DATABASE RENAME GLOBAL_NAME TO
l、重建dbconsole $ emca -config dbcontrol db -repos recreate
m、全备数据库

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



The article discusses using MySQL's ALTER TABLE statement to modify tables, including adding/dropping columns, renaming tables/columns, and changing column data types.

InnoDB's full-text search capabilities are very powerful, which can significantly improve database query efficiency and ability to process large amounts of text data. 1) InnoDB implements full-text search through inverted indexing, supporting basic and advanced search queries. 2) Use MATCH and AGAINST keywords to search, support Boolean mode and phrase search. 3) Optimization methods include using word segmentation technology, periodic rebuilding of indexes and adjusting cache size to improve performance and accuracy.

Article discusses configuring SSL/TLS encryption for MySQL, including certificate generation and verification. Main issue is using self-signed certificates' security implications.[Character count: 159]

Article discusses popular MySQL GUI tools like MySQL Workbench and phpMyAdmin, comparing their features and suitability for beginners and advanced users.[159 characters]

Article discusses strategies for handling large datasets in MySQL, including partitioning, sharding, indexing, and query optimization.

Full table scanning may be faster in MySQL than using indexes. Specific cases include: 1) the data volume is small; 2) when the query returns a large amount of data; 3) when the index column is not highly selective; 4) when the complex query. By analyzing query plans, optimizing indexes, avoiding over-index and regularly maintaining tables, you can make the best choices in practical applications.

The difference between clustered index and non-clustered index is: 1. Clustered index stores data rows in the index structure, which is suitable for querying by primary key and range. 2. The non-clustered index stores index key values and pointers to data rows, and is suitable for non-primary key column queries.

Yes, MySQL can be installed on Windows 7, and although Microsoft has stopped supporting Windows 7, MySQL is still compatible with it. However, the following points should be noted during the installation process: Download the MySQL installer for Windows. Select the appropriate version of MySQL (community or enterprise). Select the appropriate installation directory and character set during the installation process. Set the root user password and keep it properly. Connect to the database for testing. Note the compatibility and security issues on Windows 7, and it is recommended to upgrade to a supported operating system.
