修改数据库的instance_name和db_name
分成两个步骤,先修改instance_name,在修改db_name
修改SID
1.全备份数据库
RMAN> backup as compressed backupset database include current controlfile plus archivelog delete all input ;
(DBID=1698783370)
2.改环境变量中的ORACLE_SID
vi .bash_profile
3.改参数文件名称initSID.ora
mv initSBBB.ora initSBDB.ora
4.改数据文件和日志文件路径
SQL> startup mount pfile='/opt/oracle/product/11.1.0/db_1/dbs/initSBDB.ora';
$ cp *.dbf ../SBDB/
SQL> alter database rename file '/opt/oracle/oradata/SBBB/sysaux.dbf' to '/opt/oracle/oradata/SBDB/sysaux.dbf' ;
SQL> alter database rename file '/opt/oracle/oradata/SBBB/system.dbf' to '/opt/oracle/oradata/SBDB/system.dbf' ;
SQL> alter database rename file '/opt/oracle/oradata/SBBB/temp01.dbf' to '/opt/oracle/oradata/SBDB/temp01.dbf' ;
SQL> alter database rename file '/opt/oracle/oradata/SBBB/undotbs1.dbf' to '/opt/oracle/oradata/SBDB/undotbs1.dbf' ;
SQL> alter database rename file '/opt/oracle/oradata/SBBB/users01.dbf' to '/opt/oracle/oradata/SBDB/users01.dbf' ;
SQL> alter database rename file '/opt/oracle/oradata/SBBB/redo1.log' to '/opt/oracle/oradata/SBDB/redo1.log' ;
SQL> alter database rename file '/opt/oracle/oradata/SBBB/redo2.log' to '/opt/oracle/oradata/SBDB/redo2.log' ;
SQL> alter database rename file '/opt/oracle/oradata/SBBB/redo3.log' to '/opt/oracle/oradata/SBDB/redo3.log' ;
5.改密码文件
6.启动数据库,并做一个全库备份
接下来修改DB_NAME
1.先关闭后启动到mount状态
SQL> alter database mount ;
Database altered.
SQL>
SQL>
SQL>
SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
2.使用ORACLE自带的nid工具,ORACLE需要启动到mount
$ nid target=sys/ocmb123 as sysdba dbname=SBDB
DBNEWID: Release 11.1.0.6.0 - Production on Mon Mar 17 20:29:23 2014
Copyright (c) 1982, 2007, Oracle. All rights reserved.
Password:
Connected to database SBBB (DBID=1698783370)
Connected to server version 11.1.0
Control Files in database:
/opt/oracle/oradata/SBDB/control1.ctl
/opt/oracle/oradata/SBDB/control2.ctl
/opt/oracle/oradata/SBDB/control3.ctl
Change database ID and database name SBBB to SBDB? (Y/[N]) => Y
Proceeding with operation
Changing database ID from 1698783370 to 1234663846
Changing database name from SBBB to SBDB
Control File /opt/oracle/oradata/SBDB/control1.ctl - modified
Control File /opt/oracle/oradata/SBDB/control2.ctl - modified
Control File /opt/oracle/oradata/SBDB/control3.ctl - modified
Datafile /opt/oracle/oradata/SBDB/system.dbf - dbid changed, wrote new name
Datafile /opt/oracle/oradata/SBDB/sysaux.dbf - dbid changed, wrote new name
Datafile /opt/oracle/oradata/SBDB/undotbs1.dbf - dbid changed, wrote new name
Datafile /opt/oracle/oradata/SBDB/users01.dbf - dbid changed, wrote new name
Datafile /opt/oracle/oradata/SBDB/temp01.dbf - dbid changed, wrote new name
Control File /opt/oracle/oradata/SBDB/control1.ctl - dbid changed, wrote new name
Control File /opt/oracle/oradata/SBDB/control2.ctl - dbid changed, wrote new name
Control File /opt/oracle/oradata/SBDB/control3.ctl - dbid changed, wrote new name
Instance shut down
Database name changed to SBDB.
Modify parameter file and generate a new password file before restarting.
Database ID for database SBDB changed to 1234663846.
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.
修改成功后,数据库会关闭。
3.修改initSBDB.ora里面的db_name=SBDB
SQL> startup mount pfile='/opt/oracle/product/11.1.0/db_1/dbs/initSBDB.ora';
ORACLE instance started.
Total System Global Area 523108352 bytes
Fixed Size 1301024 bytes
Variable Size 318768608 bytes
Database Buffers 197132288 bytes
Redo Buffers 5906432 bytes
Database mounted.
SQL>
SQL>
SQL>
SQL> alter database open resetlogs ;
Database altered.
至此数据库完全打开,instance_name,db_name全部改好。
还有一种方法不用nid,直接重建控制文件。
alter database backup controlfile to trace resetlogs ;
trace文件中会生成create controlfile的语句,相对比较麻烦,有兴趣可以尝试下。
另一种修改DB_NAME的大致思路:
1.alter system switch logifle;
2.alter database backup controlfile to trace resetlogs ;
3.shutdown immediate
4.user_dump_dest 查看trace文件
5拷贝出create controlfile 语句,REUSE改成set ,dbnam改成新的
6.改名control files,为了备份
7.改参数文件中db_name
8.执行重建控制文件的语句,如果报错
recover database using backup controlfile until cancel ;
如果继续报错,提供状态为CURRENT的日志 v$log;
select group#,seq#,status from v$log ;
9.alter database open resetlogs ;
10.增加新的TEMP文件
alter tablespace temp add tempfile '/opt/oracle/oradata/...' size 100m resue autoextend on next 10m maxsize 32767m ;
11.改全局数据库名
alter database rename global_name to **
12.全备数据库
13.确认dbsnmp.bsln_baselines的DBID ,INSTANCE_NAME已经更改。
修改数据库的instance_name和db_name的更多相关文章
- 查看mysql字符集、修改数据库、数据表、字段字符集
查看所有表的字符集 SELECT table_name, table_type, engine, version, table_collation FROM information_schema.ta ...
- Oracle NID工具修改数据库DBID、数据库名称、数据库实例名
DBID是数据库的唯一标识符,在一些特殊场合会涉及到DBID的相关内容,本篇文章的目的是演示将DB_NAME的值从ORCL修改为ORCL1. 一.查看当前的环境 [oracle@oracledb ad ...
- MySQL创建和修改数据库语法
1.创建数据库语法: CREATE {DATABASE | SCHEMA} [IF NOT EXISTS] db_name [create_specification [, create_spe ...
- 怎样在mysql里面修改数据库名称
怎样在mysql里面修改数据库名称 提供三种方法:1. RENAME DATABASE db_name TO new_db_name这个..这个语法在mysql 5.1.7中被添加进来,到 ...
- MySQL修改数据库、表、列、外键字符编码和排序编码
在重启Confluence应用时,突然遇见这个检查错误,查询总结需要修改Mysql数据库的所有字符编码和排序编码,报错如下: Confluence Help – This installation o ...
- activiti部署流程定义时出错:INSERT INTO ACT_GE_BYTEARRAY,修改数据库编码
activiti部署流程定义时出错 // 部署流程定义 Deployment deployment = deploymentBuilder.deploy(); 错误信息:(有乱码的...没留下截图.. ...
- SQL SERVER 2005修改数据库名称,包括物理文件名和逻辑名称
SQL SERVER 2005修改数据库名称,包括物理文件名和逻辑名称 原来数据库名称为 aa,物理文件名称为 aa.mdf 和 aa_log.ldf: 需要修改数据库名称为 bb,物理文件名 ...
- SQL Server修改数据库对象所有者(Owner)浅析
在SQL Server数据库中如何修改数据库对象(表.视图.存储过程..)的所有者(Owner)呢?一般我们可以使用系统提供的系统存储过程sp_changeobjectowner来修改. 我们先看看s ...
- SQL SERVER 2012 修改数据库默认位置不立即生效
今天修改SQL SERVER 2012的数据库默认位置:即数据文件.日志文件默认位置时遇到一个问题,单击"服务器属性"(Server Properties)--> 数据库设置 ...
随机推荐
- django2 xadmin pip list
diff-match-patch 20121119Django 2.0.5django-crispy-forms 1.7.2django-formtools 2.1django-import-expo ...
- BZOJ3033: 太鼓达人(欧拉回路)
Time Limit: 1 Sec Memory Limit: 128 MBSubmit: 524 Solved: 400[Submit][Status][Discuss] Description ...
- C#访问加密的SQLite数据库
前提:一个项目需要存储各种密码数据,使用的嵌入式的SQLite数据库.默认的SQLite数据库是没有加密的,这样相当不安全.找呀找呀找方法... 方法: 1.使用SQLite管理器加密. 部分SQLi ...
- test20181018 B君的第三题
题意 B 君的第三题(shenyang) 题目描述 客似云来,万里无云 B 君得到了一个数组\(\{a_1,a_2,\dots,a_n\}\). B 君想通过修改让数组中个每对数都互质. 每次使一个数 ...
- 【转】Ubuntu13.04配置:Vim+Syntastic+Vundle+YouCompleteMe
原文网址:http://www.cnblogs.com/csuftzzk/p/3435710.html 序言 使用Ubuntu和vim已经有一段时间了,对于Vim下的插件应用,我总是抱着一股狂热的态度 ...
- Django models中关于blank与null
建立一个简易Model class Person(models.Model): GENDER_CHOICES=( (1,'Male'), (2,'Female'), ) name=models.Cha ...
- Phonegap Android 项目使用Cordova
要在已经创建好的Android项目里,使用Cordova. 1. 首先在Android Studio中创建Android项目 2. 创建cordova项目 cordova crate test com ...
- JAVA面向对象编程课程设计——web版斗地主
一.团队课程设计博客链接 JAVA面向对象编程课程设计--网络版单机斗地主 二.个人负责模块或任务说明 实体类的设计 斗地主规则的实现 人机自动出牌的算法 实现数据库的DAO模式 三.自己的代码提交记 ...
- 分类预测输出precision,recall,accuracy,auc和tp,tn,fp,fn矩阵
此次我做的实验是二分类问题,输出precision,recall,accuracy,auc # -*- coding: utf-8 -*- #from sklearn.neighbors import ...
- Golang后台开发初体验
转自:http://blog.csdn.net/cszhouwei/article/details/37740277 补充反馈 slice 既然聊到slice,就不得不提它的近亲array,这里不太想 ...