修改Oracle数据库的名字
最近闲来无事,决定修改一下数据库的名字,记得曾经学过通过重建控制文件来修改数据库的名字,网上找了下也可以通过oracle自带的
最近闲来无事,决定修改一下数据库的名字,记得曾经学过通过重建控制文件来修改数据库的名字,网上找了下也可以通过Oracle自带的nid修改数据库的名字,不过这个方法有些麻烦,并且修改的数据库名字不能带“_"。
1,通过重建控制文件修改数据库名字。
为了方便查找trace文件我们在进行备份控制文件的时候我们可以标记下trace文件:
alter session set tracefile_identifier='control_bak'
下面我们备份我们的控制文件:
alter database backup controlfile to trace;
10g是在我们的$ORACLE_BASE/admin\orcl\bdump下面的包含”control_bak“的文件
11g是在我们的$ORACLE_BASE/diag/rdbms/orcl/orcl/trace下面包含的”control_bak的文件
无论是那个版本的数据库我们可以通过查询查找到trace文件的路径
select * from v$diag_info;
关闭数据库,,删除控制文件(如果我们想要复制数据库,我们可以把所有的文件复制到相应的位置,包括数据文件,归档文件,在线日志文件和和网络有关的三个文件;不需要复制控制文件)
单纯的修改数据库的名字这步可以省略,我们需要修改pfile文件:主要是修改数据库的文件路径和数据库的名字,以修改后的数据文件启动新库到nomount阶段。
打开刚才找到的trace文件,复制创建控制文件的一段(一般以CREATE CONTROLFILE 开始)
我们需要修改两个地方:
1,将“REUSE”修改为“set”,原数据库名修改数据库名,其他文件的路径按需修改
· 2,需要移除RECOVER DATABASE USING BACKUP CONTROLFILE这一句
执行我们复制的脚步
以resetlog的方式打开我们的数据库
alter database open resetlogs;
启用临时文件
alter tablespace temp add tempfile '/.../temp01.dbf' reuse;
如果只是修改数据库的名字这一步可以省略。
可以正常打开表示修改数据库的名字成功
2,通过nid修改数据库的名字
启动数据库到mount阶段,修改数据库的名字
startup mount;
host nid target=sys/orcl dbname=new_name
关闭再次启动到mount阶段
alter system set db_name=new_name scope=spfile;
shutdown immediate;
重建控制文件
host orapwd file=/../pwdorcl.ora password=orcl entries=5(其实这个参数用处不大,多少个这样的用户是根据系统来设置的)
以resetlogs方式打开
startup mount;
alter database open resetlogs;
查看数据库的名字
select dbid,name from v$database;
更改数据库的instance_name,windows下面停止所有的服务
重建实例
oradim -delete -sid old_name;
oradim -new -sid new_name -intpwd pwd -startmode a -pfile c:\..\initonew_name.ora(修改原来的参数文件)
进入到数据库中创建spfile文件
set oracle_sid=new_name
sqlplus sys/orcl as sysdba
create spfile from pfile='c:\..\initnew_name.ora';
重新载入监听文件
lsnrctl reload;
如果不能启动可以执行resetlogs
alter database open resetlogs;
在使用2方法修改数据库的名字的时候切忌修改的名字不能带“_",否则会报:DIM-00003: 参数缺失变元。
网上查了下是oracle的一个bug,Oracle在Bug No. 6000490中进行了描述。
解决方式就是去掉”_",并说这个bug已经提交进行到开发,但是要等到12版本才能解决。
目前解决方式只能是去掉下划线。

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics











Apple's latest releases of iOS18, iPadOS18 and macOS Sequoia systems have added an important feature to the Photos application, designed to help users easily recover photos and videos lost or damaged due to various reasons. The new feature introduces an album called "Recovered" in the Tools section of the Photos app that will automatically appear when a user has pictures or videos on their device that are not part of their photo library. The emergence of the "Recovered" album provides a solution for photos and videos lost due to database corruption, the camera application not saving to the photo library correctly, or a third-party application managing the photo library. Users only need a few simple steps

MySQL is an open source relational database management system. 1) Create database and tables: Use the CREATEDATABASE and CREATETABLE commands. 2) Basic operations: INSERT, UPDATE, DELETE and SELECT. 3) Advanced operations: JOIN, subquery and transaction processing. 4) Debugging skills: Check syntax, data type and permissions. 5) Optimization suggestions: Use indexes, avoid SELECT* and use transactions.

This article recommends the top ten digital currency trading apps in the world, including Binance, OKX, Huobi Global, Coinbase, Kraken, Gate.io, KuCoin, Bitfinex, Gemini and Bitstamp. These platforms have their own characteristics in terms of transaction pair quantity, transaction speed, security, compliance, user experience, etc. For example, Binance is known for its high transaction speed and extensive services, while Coinbase is more suitable for novices. Choosing a platform that suits you requires comprehensive consideration of your own needs and risk tolerance. Learn about the world's mainstream digital currency trading platforms to help you conduct digital asset trading safely and efficiently.

This article will provide a detailed introduction to how to install and register a Bitcoin trading application. The Bitcoin trading app allows users to manage and trade cryptocurrencies such as Bitcoin. The article guides users through the installation and registration process step by step, including downloading applications, creating accounts, performing identity verification, and first deposit. The goal of the article is to provide beginners with clear and easy-to-understand guidelines to help them easily enter the world of Bitcoin trading.

MySQL is an open source relational database management system, mainly used to store and retrieve data quickly and reliably. Its working principle includes client requests, query resolution, execution of queries and return results. Examples of usage include creating tables, inserting and querying data, and advanced features such as JOIN operations. Common errors involve SQL syntax, data types, and permissions, and optimization suggestions include the use of indexes, optimized queries, and partitioning of tables.

MySQL is chosen for its performance, reliability, ease of use, and community support. 1.MySQL provides efficient data storage and retrieval functions, supporting multiple data types and advanced query operations. 2. Adopt client-server architecture and multiple storage engines to support transaction and query optimization. 3. Easy to use, supports a variety of operating systems and programming languages. 4. Have strong community support and provide rich resources and solutions.

Ouyi, also known as OKX, is a world-leading cryptocurrency trading platform. The article provides a download portal for Ouyi's official installation package, which facilitates users to install Ouyi client on different devices. This installation package supports Windows, Mac, Android and iOS systems. Users can choose the corresponding version to download according to their device type. After the installation is completed, users can register or log in to the Ouyi account, start trading cryptocurrencies and enjoy other services provided by the platform.

MySQL is suitable for web applications and content management systems and is popular for its open source, high performance and ease of use. 1) Compared with PostgreSQL, MySQL performs better in simple queries and high concurrent read operations. 2) Compared with Oracle, MySQL is more popular among small and medium-sized enterprises because of its open source and low cost. 3) Compared with Microsoft SQL Server, MySQL is more suitable for cross-platform applications. 4) Unlike MongoDB, MySQL is more suitable for structured data and transaction processing.
