DBID是数据库的唯一标识符,在一些特殊场合会涉及到DBID的相关内容,本篇文章的目的是演示将DB_NAME的值从ORCL修改为ORCL1。

一.查看当前的环境

[oracle@oracledb admin]$ echo $ORACLE_SID
orcl
[oracle@oracledb admin]$ sqlplus sys as sysdba SQL*Plus: Release 11.2.0.1.0 Production on Thu Dec 17 09:34:51 2015 Copyright (c) 1982, 2009, Oracle. All rights reserved. Enter password: Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options SQL> show parameter db_name NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
db_name string orcl
SQL> show parameter service_name NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
service_names string orcl
SQL> show parameter instance_name NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
instance_name string orcl
SQL> select dbid,name from v$database; DBID NAME
---------- ---------
1424428733 ORCL SQL> host lsnrctl status LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 17-DEC-2015 09:36:52 Copyright (c) 1991, 2009, Oracle. All rights reserved. Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 11.2.0.1.0 - Production
Start Date 17-DEC-2015 09:32:02
Uptime 0 days 0 hr. 4 min. 49 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /usr/oracle/app/product/11.2.0/dbhome_1/network/admin/listener.ora
Listener Log File /usr/oracle/app/diag/tnslsnr/oracledb/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=oracledb)(PORT=1521)))
Services Summary...
Service "orcl" has 1 instance(s).
Instance "orcl", status READY, has 1 handler(s) for this service...
Service "orclXDB" has 1 instance(s).
Instance "orcl", status READY, has 1 handler(s) for this service...
The command completed successfully

二.启动数据库到MOUNT模式。

SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup mount
ORACLE instance started. Total System Global Area 3290345472 bytes
Fixed Size 2217832 bytes
Variable Size 1795164312 bytes
Database Buffers 1476395008 bytes
Redo Buffers 16568320 bytes
Database mounted.

三.使用NID工具将DB_NAME从orcl修改为orcl1。

[oracle@oracledb admin]$ nid target=sys/wangshengzhuang dbname=orcl1

DBNEWID: Release 11.2.0.1.0 - Production on Thu Dec 17 09:40:47 2015

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

Connected to database ORCL (DBID=1424428733)

Connected to server version 11.2.0

Control Files in database:
/usr/oracle/app/oradata/orcl/control01.ctl
/usr/oracle/app/flash_recovery_area/orcl/control02.ctl Change database ID and database name ORCL to ORCL1? (Y/[N]) => Y Proceeding with operation
Changing database ID from 1424428733 to 1283125855
Changing database name from ORCL to ORCL1
Control File /usr/oracle/app/oradata/orcl/control01.ctl - modified
Control File /usr/oracle/app/flash_recovery_area/orcl/control02.ctl - modified
Datafile /usr/oracle/app/oradata/orcl/system01.db - dbid changed, wrote new name
Datafile /usr/oracle/app/oradata/orcl/sysaux01.db - dbid changed, wrote new name
Datafile /usr/oracle/app/oradata/orcl/undotbs01.db - dbid changed, wrote new name
Datafile /usr/oracle/app/oradata/orcl/users01.db - dbid changed, wrote new name
Datafile /usr/oracle/app/oradata/orcl/example01.db - dbid changed, wrote new name
Datafile /usr/oracle/app/oradata/orcl/temp01.db - dbid changed, wrote new name
Control File /usr/oracle/app/oradata/orcl/control01.ctl - dbid changed, wrote new name
Control File /usr/oracle/app/flash_recovery_area/orcl/control02.ctl - dbid changed, wrote new name
Instance shut down Database name changed to ORCL1.
Modify parameter file and generate a new password file before restarting.
Database ID for database ORCL1 changed to 1283125855.
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. [oracle@oracledb admin]$

四.新建密码文件。

[oracle@oracledb admin]$ orapwd file=$ORACLE_HOME/dbs/orapworcl1 password=wangshengzhuang  entries=5

五.修改参数文件中的DB_NAME参数值。

由于nid修改了控制文件和数据文件中的DB_NAME值,所以将参数文件中的DB_NAME修改来和控制文件、数据文件相同,修改为ORCL1。

[oracle@oracledb admin]$ sqlplus sys as sysdba

SQL*Plus: Release 11.2.0.1.0 Production on Thu Dec 17 09:48:14 2015

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

Enter password:
Connected to an idle instance. SQL> startup nomount
ORACLE instance started. Total System Global Area 3290345472 bytes
Fixed Size 2217832 bytes
Variable Size 1795164312 bytes
Database Buffers 1476395008 bytes
Redo Buffers 16568320 bytes
SQL> show parameter db_name NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
db_name string orcl
SQL> alter system set db_name=orcl1 scope=spfile; System altered. SQL> shutdown immediate
ORA-01507: database not mounted ORACLE instance shut down.
SQL> startup mount
ORACLE instance started. Total System Global Area 3290345472 bytes
Fixed Size 2217832 bytes
Variable Size 1795164312 bytes
Database Buffers 1476395008 bytes
Redo Buffers 16568320 bytes
Database mounted.
SQL> alter database open resetlogs; Database altered. SQL> show parameter db_name NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
db_name string ORCL1
SQL>

六.查看修改后的环境

修改后的数据库DB_NAME和Service_name都会自动发生变化,instance_name不会发生变化。

SQL> show parameter db_name

NAME                     TYPE     VALUE
------------------------------------ ----------- ------------------------------
db_name string ORCL1
SQL> show parameter service NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
service_names string ORCL1
SQL> show parameter instance_nam NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
instance_name string orcl
SQL> select dbid,name from v$database; DBID NAME
---------- ---------
1283125855 ORCL1 SQL> host lsnrctl status LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 17-DEC-2015 09:52:23 Copyright (c) 1991, 2009, Oracle. All rights reserved. Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 11.2.0.1.0 - Production
Start Date 17-DEC-2015 09:32:02
Uptime 0 days 0 hr. 20 min. 20 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /usr/oracle/app/product/11.2.0/dbhome_1/network/admin/listener.ora
Listener Log File /usr/oracle/app/diag/tnslsnr/oracledb/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=oracledb)(PORT=1521)))
Services Summary...
Service "ORCL1" has 1 instance(s).
Instance "orcl", status READY, has 1 handler(s) for this service...
Service "orclXDB" has 1 instance(s).
Instance "orcl", status READY, has 1 handler(s) for this service...
The command completed successfully SQL>

七、修改实例名

修改.bash_profile 中的ORACLE_SID

vi  .bash_profile

使修改生效

source  .bash_profile

修改参数文件路径

[oracle@oracledb ~]$ cd $ORACLE_HOME/dbs
[oracle@oracledb dbs]$ pwd
/usr/oracle/app/product/11.2.0/dbhome_1/dbs
[oracle@oracledb dbs]$ mv spfileorcl.ora spfileorcl1.ora
[oracle@oracledb dbs]$ mv initorcl.ora initorcl1.ora

重启数据库,查看实例名

[oracle@oracledb dbs]$ sqlplus sys as sysdba

SQL*Plus: Release 11.2.0.1.0 Production on Thu Dec 17 10:03:21 2015

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

Enter password: ***************
Connected to an idle instance. SQL> startup
ORACLE instance started. Total System Global Area 3290345472 bytes
Fixed Size 2217832 bytes
Variable Size 1795164312 bytes
Database Buffers 1476395008 bytes
Redo Buffers 16568320 bytes
Database mounted.
Database opened.
SQL> show parameter instance_name; NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
instance_name string orcl1

Oracle NID工具修改数据库DBID、数据库名称、数据库实例名的更多相关文章

  1. T-SQL - query02_查看数据库信息|查看服务器名称|查看实例名

    时间:2017-09-29 编辑:byzqy 本篇记录几个查询数据库信息的 T-SQL 语句: 查看数据库信息 查看服务器名称 查看实例名 文件:SQLQuery2.sql /* 说明: SQLQue ...

  2. 8. DBNEWID 工具(使用nid命令修改db name及dbid)

    以下参考自:https://www.2cto.com/database/201305/207860.html Oralce官网:https://docs.oracle.com/cd/E11882_01 ...

  3. 电脑上不安装Oracle时,C# 调用oracle数据库,Oracle客户工具

    Oracle的安装包通常都比较大,安装又比较费时,而且如果安装过程中不幸出错,各种蛋疼,即便是安装过N遍的老手,有时候安装起来也觉得挺烦.而工作中,通常服务器上面安装oracle就可以了,我们本地电脑 ...

  4. oracle通过修改控制文件scn推进数据库scn

    数据库当前scn 代码如下 复制代码 idle> select checkpoint_change# from v$database; CHECKPOINT_CHANGE#----------- ...

  5. 使用Oracle 9i工具管理数据库 - 初学者系列 - 学习者系列文章

    前面介绍了Oracle 9i的安装,本文大概介绍下Oracle 9i提供的管理工具的使用. 1 打开数据库配置工具 2 下一步 3 下一步 4 下一步.这里输入数据库名和SID 5 下一步 6 下一步 ...

  6. 电脑上不安装Oracle时,C# 调用oracle数据库,Oracle客户工具 【转载】

    http://www.cnblogs.com/jiekzou/p/5047850.html Oracle的安装包通常都比较大,安装又比较费时,而且如果安装过程中不幸出错,各种蛋疼,即便是安装过N遍的老 ...

  7. 【ORACLE】Win2008R2修改oracle数据库实例名

    需求说明:要求将windows平台的数据库实例名由orcl改为haha 参考: https://www.cnblogs.com/junnor/archive/2013/03/05/2945245.ht ...

  8. 如何修改SQL Server 2000的数据库逻辑与物理名称

    在项目中使用SQL Server 2000创建了一个数据库,发现名称与另一个数据库太相似,于是决定更改名称,包括: 在企业管理器中看到的数据库名,也是实际应用程序中连接用的数据库名称: 在磁盘上看的物 ...

  9. 详解:数据库名、实例名、ORACLE_SID、数据库域名、全局数据库名、服务名及手工脚本创建oracle数据库

    数据库名.实例名.数据库域名.全局数据库名.服务名 , 这是几个令很多初学者容易混淆的概念.相信很多初学者都与我一样被标题上这些个概念搞得一头雾水.我们现在就来把它们弄个明白. 一.数据库名 什么是数 ...

随机推荐

  1. 线程池 多线程运行结束后 如何关闭? ExecutorService的正确关闭方法

    前言 最近在使用ExecutorService的时候,对于与ExecutorService相关的概念有些迷糊, 加上本身ExecutorService内部的有些方法名在取名上也容易让使用者误解,导致 ...

  2. #8 //HDU 5730 Shell Necklace(CDQ分治+FFT)

    Description 给出长度分别为1~n的珠子,长度为i的珠子有a[i]种,每种珠子有无限个,问用这些珠子串成长度为n的链有多少种方案 题解: dp[i]表示组合成包含i个贝壳的项链的总方案数 转 ...

  3. BZOJ1258 [CQOI2007]三角形tri 模拟

    欢迎访问~原文出处——博客园-zhouzhendong 去博客园看该题解 题目传送门 - BZOJ1258 题意概括 这种图中,一个三角形的三边如果被其他某一个三角形的一条边包括,那么我们说该三角形和 ...

  4. AndroidStudio 之 Inter x86 Emulator Accelerator(Haxm installer) - not compatible with windows

  5. (转)HIBERNATE与 MYBATIS的对比

    第一方面:开发速度的对比 就开发速度而言,Hibernate的真正掌握要比Mybatis来得难些.Mybatis框架相对简单很容易上手,但也相对简陋些.个人觉得要用好Mybatis还是首先要先理解好H ...

  6. (转)java代码发送JSON格式的httpPOST请求

    import Java.io.BufferedReader; import java.io.DataOutputStream; import java.io.IOException; import j ...

  7. ARIMA模型---时间序列分析---温度预测

    (图片来自百度) 数据 分析数据第一步还是套路------画图 数据看上去比较平整,但是由于数据太对看不出具体情况,于是将只取前300个数据再此画图 这数据看上去很不错,感觉有隐藏周期的意思 代码 # ...

  8. 机器学习数据处理时label错位对未来数据做预测

    这篇文章继上篇机器学习经典模型简单使用及归一化(标准化)影响,通过将测试集label(行)错位,将部分数据作为对未来的预测,观察其效果. 实验方式 以不同方式划分数据集和测试集 使用不同的归一化(标准 ...

  9. 移动端Tap与滑屏实战技巧总结以及Vue混合开发自定义指令

    最近在忙混合开发,因交互相对复杂,所以也踩了很多坑.在此做一下总结. 1.tap事件的实际应用 在使用tap事件时,老生常谈的肯定是点透问题,大多情况下,在有滑屏交互的页面时,我们会在根节点阻止默认行 ...

  10. Linux输入设备详解

    <什么是Linux输入设备> ➤简介      Linux输入设备总类繁杂,常见的包括有按键.键盘.触摸屏.鼠标.摇杆等等,他们本身就是字符设备,而linux内核将这些设备的共同性抽象出来 ...