Oracle 怎樣修改DB_NAME
2023-12-13 07:43:33
DBNEWID 是一个数据库实用程序,用于更改 Oracle 数据库的 DBNAME 和 DBID。可以更改 DBID 或 DBNAME 或两者。
DBNAME 是在创建数据库时指定的数据库名称,DBID 是创建数据库时分配给数据库的唯一编号。
以下步骤演示如何使用 DBNEWID 实用程序更改 Oracle 数据库的 DBNAME 和 DBID。
重要提示:开始此过程之前,请确保拥有数据库的完整备份。
Step 1:开始之前,找出数据库当前的 DBNAME 和 DBID:
SQL> SELECT DBID,NAME from V$DATABASE;
DBID NAME
---------- ---------
2426088413 MYORDB
Step 2:第一步是启动实例并挂载数据库,但不打开数据库。
sqlplus / as sysdba
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup mount
ORACLE instance started.
Total System Global Area 1071333376 bytes
Fixed Size 1375792 bytes
Variable Size 553648592 bytes
Database Buffers 511705088 bytes
Redo Buffers 4603904 bytes
Database mounted.
SQL> exit
Disconnected from Oracle Database 11g Release 11.2.0.1.0 - Production
Step 3. 通过指定连接字符串和数据库的新名称来运行 DBNEWID 实用程序。 连接字符串中指定的用户应具有 SYSDBA 权限。
nid target=sys/MYPASS@MYORDB dbname=MYNEWDB setname=YES
DBNEWID: Release 11.2.0.1.0 - Production on Tue May 30 12:50:01 2015
Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
Connected to database MYORDB (DBID=2436089413)
Connected to server version 11.2.0
Control Files in database:
C:ORADATAMYORDBCONTROL01.CTL
C:ORADATAMYORDBCONTROL02.CTL
Change database name of database MYORDB to MYNEWDB? (Y/[N]) => Y
Proceeding with operation
Changing database name from MYORDB to MYNEWDB
Control File C:ORADATAMYORDBCONTROL01.CTL - modified
Datafile C:ORADATAMYORDBSYSTEM01.DB - wrote new name
Datafile C:ORADATAMYORDBSYSAUX01.DB - wrote new name
Datafile C:ORADATAMYORDBUNDOTBS01.DB - wrote new name
Datafile C:ORADATAMYORDBUSERS01.DB - wrote new name
Datafile C:ORADATAMYORDBMYORDBDAT01.DB - wrote new name
Datafile C:ORADATAMYORDBMYORDBIDX01.DB - wrote new name
Datafile C:ORADATAMYORDBTEMP01.DB - wrote new name
Control File C:ORADATAMYORDBCONTROL01.CTL - wrote new name
Control File C:ORADATAMYORDBCONTROL02.CTL - wrote new name
Instance shut down
Database name changed to MYNEWDB.
Modify parameter file and generate a new password file before restarting.
Succesfully changed database name.
DBNEWID - Completed succesfully.
Step 4: Shut down the database.
SQL> shutdown immediate
Step 5:将初始化参数文件中的DB_NAME初始化参数设置为新的数据库名称。
sqlplus / as sysdba
SQL> show parameter db_name
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
db_name string MYORDB
SQL> alter system set db_name=MYNEWDB scope=spfile;
System altered.
Step 6: 创建一个新的密码文件。
orapwd file=orapwMYNEWDB password=MYPASS
Step 7: 启动DB
SQL> startup mount
Step 8:验证名称更改
SELECT DBID,NAME from V$DATABASE;
DBID NAME
---------- ---------
2426088413 MYNEWDB
文章来源:https://blog.csdn.net/weixin_43230594/article/details/134901000
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。 如若内容造成侵权/违法违规/事实不符,请联系我的编程经验分享网邮箱:veading@qq.com进行投诉反馈,一经查实,立即删除!
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。 如若内容造成侵权/违法违规/事实不符,请联系我的编程经验分享网邮箱:veading@qq.com进行投诉反馈,一经查实,立即删除!