ORACLE修改实例名和dbname方法

1 登陆数据库把数据库变成mount状态

sql 复制代码
C:\>sqlplus /nolog
 
SQL*Plus: Release 9.2.0.1.0 - Production on 星期一 4月 17 15:10:42 2006
 
Copyright (c) 1982, 2002, Oracle Corporation.  All rights reserved.
 
SQL> conn /as sysdba
已连接。
NAME                                 TYPE        VALUE
------------------------------------ ----------- ---------------
db_file_name_convert                 string
db_name                              string      drew
global_names                         boolean     FALSE
instance_name                        string      drew
 
SQL> shutdown immediate;
数据库已经关闭。
已经卸载数据库。
ORACLE 例程已经关闭。
SQL> startup mount
ORACLE 例程已经启动。
 
Total System Global Area  135338868 bytes
Fixed Size                   453492 bytes
Variable Size             109051904 bytes
Database Buffers           25165824 bytes
Redo Buffers                 667648 bytes
数据库装载完毕。
SQL>

2 使用NID命令来修改数据库instanc_name和dbname

sql 复制代码
 C:\>nid target=sys/oracle@drew dbname=kbdv2
DBNEWID: Release 9.2.0.1.0 - Production
Copyright (c) 1995, 2002, Oracle Corporation.  All rights reserved.
 
Connected to database DREW (DBID=2198138346)
 
Control Files in database:
    D:\ORACLE\ORADATA\TEST\CONTROL01.CTL
    D:\ORACLE\ORADATA\TEST\CONTROL02.CTL
    D:\ORACLE\ORADATA\TEST\CONTROL03.CTL
 
Change database ID and database name DREW to KBDV2? (Y/[N]) => Y
 
Proceeding with operation
Changing database ID from 2198138346 to 1048877256
Changing database name from DREW to KBDV2
    Control File D:\ORACLE\ORADATA\TEST\CONTROL01.CTL - modified
    Control File D:\ORACLE\ORADATA\TEST\CONTROL02.CTL - modified
    Control File D:\ORACLE\ORADATA\TEST\CONTROL03.CTL - modified
    Datafile D:\ORACLE\ORADATA\TEST\SYSTEM01.DBF - dbid changed, wrote new name
    Datafile D:\ORACLE\ORADATA\TEST\UNDOTBS01.DBF - dbid changed, wrote new name
    Datafile D:\ORACLE\ORADATA\TEST\DRSYS01.DBF - dbid changed, wrote new name
    Datafile D:\ORACLE\ORADATA\TEST\INDX01.DBF - dbid changed, wrote new name
    Datafile D:\ORACLE\ORADATA\TEST\TOOLS01.DBF - dbid changed, wrote new name
    Datafile D:\ORACLE\ORADATA\TEST\USERS01.DBF - dbid changed, wrote new name
    Datafile D:\ORACLE\ORADATA\TEST\XDB01.DBF - dbid changed, wrote new name
    Datafile D:\ORACLE\ORADATA\TEST\TEMP01.DBF - dbid changed, wrote new name
    Control File D:\ORACLE\ORADATA\TEST\CONTROL01.CTL - dbid changed, wrote new name
    Control File D:\ORACLE\ORADATA\TEST\CONTROL02.CTL - dbid changed, wrote new name
    Control File D:\ORACLE\ORADATA\TEST\CONTROL03.CTL - dbid changed, wrote new name
 
Database name changed to KBDV2.
Modify parameter file and generate a new password file before restarting.
Database ID for database KBDV2 changed to 1048877256.
All previous backups and archived redo logs for this database are unusable.
Shut down database and open with RESETLOGS option.
Succesfully changed database name and ID.
DBNEWID - Completed succesfully. 
 
SQL> shutdown immediate;
ORA-01109: 数据库未打开
 
 
已经卸载数据库。
ORACLE 例程已经关闭。

3 修改创建参数文件(pfile/Spfile)

sql 复制代码
 instance_name=kbdv2
 
###########################################
# Miscellaneous
###########################################
compatible=9.2.0.0.0
 
###########################################
# Security and Auditing
###########################################
remote_login_passwordfile=EXCLUSIVE
 
###########################################
# Sort, Hash Joins, Bitmap Indexes
###########################################
pga_aggregate_target=25165824
sort_area_size=524288
 
###########################################
# Database Identification
###########################################
db_domain=""
db_name=kbdv2
 
SQL> CREATE SPFILE FROM PFILE='D:\oracle\admin\test\pfile\init.ora';
 
文件已创建。

4 创建修改口令文件[区别windows系统和unix(linux)系统]

本人操作是在windows系统下的,所以先修改物理服务名

sql 复制代码
C:\>oradim -edit -sid drew -newsid kbdv2
并且修改注册表 HKEY_LOCAL_MACHINE\SOFTWARE\ORACLE\HOME0\ORACLE_SID

如果是unix系统,就在oracle用户下修改.profile里的oracle_sid

创建口令文件

sql 复制代码
orapwd file=D:\oracle\ora92\database\PWDkbdv2.ora password=oracle entries=5

修改listener.ora和tnsname.ora文件

sql 复制代码
LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS_LIST =
        (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC0))
      )
      (ADDRESS_LIST =
        (ADDRESS = (PROTOCOL = TCP)(HOST = 127.0.0.1)(PORT = 1521))
      )
    )
  )
 
SID_LIST_LISTENER =
  (SID_LIST =
    (SID_DESC =
      (SID_NAME = PLSExtProc)
      (ORACLE_HOME = d:\oracle\ora92)
      (PROGRAM = extproc)
    )
    (SID_DESC =
      (GLOBAL_DBNAME = kbdv2)
      (ORACLE_HOME = d:\oracle\ora92)
      (SID_NAME = kbdv2)
    )
  )
 
 
kbdv2 =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC0))
    )
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = kbdv2)
    )
  )

5 登陆数据库检查修改是否正确

sql 复制代码
SQL> startup
ORACLE 例程已经启动。
 
Total System Global Area  135338868 bytes
Fixed Size                   453492 bytes
Variable Size             109051904 bytes
Database Buffers           25165824 bytes
Redo Buffers                 667648 bytes
数据库装载完毕。
ORA-01589: 要打开数据库则必须使用 RESETLOGS 或 NORESETLOGS 选项
SQL> alter database open resetlogs;
 
数据库已更改。
 
SQL> show parameter name
 
NAME                                 TYPE        VALUE
------------------------------------ ----------- -----------
db_file_name_convert                 string
db_name                              string      kbdv2
global_names                         boolean     FALSE
instance_name                        string      kbdv2
 
 
SQL> select instance_name from v$instance;
 
INSTANCE_NAME
----------------
kbdv2

这样数据库的instance和dbname就全部修改完成

相关推荐
时差95320 分钟前
【面试题】Hive 查询:如何查找用户连续三天登录的记录
大数据·数据库·hive·sql·面试·database
让学习成为一种生活方式22 分钟前
R包下载太慢安装中止的解决策略-R语言003
java·数据库·r语言
Mephisto.java28 分钟前
【大数据学习 | kafka高级部分】kafka的优化参数整理
大数据·sql·oracle·kafka·json·database
成都古河云41 分钟前
智慧场馆:安全、节能与智能化管理的未来
大数据·运维·人工智能·安全·智慧城市
算法与编程之美43 分钟前
文件的写入与读取
linux·运维·服务器
秋意钟1 小时前
MySQL日期类型选择建议
数据库·mysql
山海青风1 小时前
第七篇: BigQuery中的复杂SQL查询
sql·googlecloud
Amelio_Ming1 小时前
Permissions 0755 for ‘/etc/ssh/ssh_host_rsa_key‘ are too open.问题解决
linux·运维·ssh
心灵彼岸-诗和远方1 小时前
Devops业务价值流:软件研发最佳实践
运维·产品经理·devops
Dxy12393102162 小时前
python下载pdf
数据库·python·pdf