工作中不可避免地碰到需要修改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、全备数据库

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

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 strategies for handling large datasets in MySQL, including partitioning, sharding, indexing, and query optimization.

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

The article discusses dropping tables in MySQL using the DROP TABLE statement, emphasizing precautions and risks. It highlights that the action is irreversible without backups, detailing recovery methods and potential production environment hazards.

Article discusses using foreign keys to represent relationships in databases, focusing on best practices, data integrity, and common pitfalls to avoid.

The article discusses creating indexes on JSON columns in various databases like PostgreSQL, MySQL, and MongoDB to enhance query performance. It explains the syntax and benefits of indexing specific JSON paths, and lists supported database systems.

Article discusses securing MySQL against SQL injection and brute-force attacks using prepared statements, input validation, and strong password policies.(159 characters)


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

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

Dreamweaver CS6
Visual web development tools

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

WebStorm Mac version
Useful JavaScript development tools

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.