Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to modify the database dbname directly without deleting the library in ORACLE

2025-01-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly introduces how to modify the database dbname directly without deleting the database in ORACLE. It is very detailed and has certain reference value. Interested friends must finish reading it.

Environment: Red 6.4 ORACLE:11.2.0.4

Original library dbname:mai

New library dname:prod

To verify that the data is modified after changing the dbname, do the following:

Original library: mai

SQL > alter user hr identified by oracle123 account unlock

SQL > conn hr/oracle

SQL > create table abc (id int,name varchar (20))

SQL > insert into abc (1 'ok',2' sdad')

SQL > commit

Commit complete.

SQL > create pfile='initprod.ora' from spfile

SQL >! nid target=sys/oracle123 dbname=prod logfile=/tmp/change.log

SQL > shu immediate

ORA-03135: connection lost contact

At this point, you need to exit sqlplus and reassign ORACLE_SID.

[oracle@node1 ~] $export ORACLE_SID=prod

[oracle@node1 ~] $sqlplus / as sysdba

Start the database to mount

SQL > startup mount

ORACLE instance started.

Total System Global Area 4275781632 bytes

Fixed Size 2260088 bytes

Variable Size 1157628808 bytes

Database Buffers 3103784960 bytes

Redo Buffers 12107776 bytes

ORA-01103: database name 'PROD' in control file is not' MAI'

SQL > alter system set db_name=prod scope=spfile; # # an error was reported because spfile was not used

Alter system set db_name=prod scope=spfile

*

ERROR at line 1:

ORA-32001: write to SPFILE requested but no SPFILE is in use

Create spfile

SQL > create spfile from pfile

File created.

Close the library to make it use spfile

SQL > shu immediate

ORA-01507: database not mounted

ORACLE instance shut down.

SQL > startup mount

ORACLE instance started.

Total System Global Area 4275781632 bytes

Fixed Size 2260088 bytes

Variable Size 1157628808 bytes

Database Buffers 3103784960 bytes

Redo Buffers 12107776 bytes

ORA-01103: database name 'PROD' in control file is not' MAI'

Modify dbname

SQL > alter system set db_name=prod scope=spfile

System altered.

Restart the database

SQL > shu immediate

ORA-01507: database not mounted

New library: prod

ORACLE instance shut down.

SQL > startup mount

ORACLE instance started.

Open the database

SQL > alter database open resetlogs

Database altered.

SQL > show parameter name

NAME TYPE VALUE

-

Cell_offloadgroup_name string

Db_file_name_convert string

Db_name string PROD

Db_unique_name string PROD

Global_names boolean FALSE

Instance_name string prod

Lock_name_space string

Log_file_name_convert string

Processor_group_name string

Service_names string PROD

Verify that data is lost

SQL > select USERNAME,ACCOUNT_STATUS from dba_users

USERNAME ACCOUNT_STATUS

SYS OPEN

SYSTEM OPEN

HR OPEN

OUTLN EXPIRED & LOCKED

Connect hr users

SQL > conn hr/oracle

SQL > select * from abc

ID NAME

--

1 ok

2 sdad

The above is all the contents of the article "how to modify the database dbname directly without deleting the database in ORACLE". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report