search
HomeDatabaseMysql Tutorial修改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版本才能解决。

目前解决方式只能是去掉下划线。

linux

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
What Are the Limitations of Using Views in MySQL?What Are the Limitations of Using Views in MySQL?May 14, 2025 am 12:10 AM

MySQLviewshavelimitations:1)Theydon'tsupportallSQLoperations,restrictingdatamanipulationthroughviewswithjoinsorsubqueries.2)Theycanimpactperformance,especiallywithcomplexqueriesorlargedatasets.3)Viewsdon'tstoredata,potentiallyleadingtooutdatedinforma

Securing Your MySQL Database: Adding Users and Granting PrivilegesSecuring Your MySQL Database: Adding Users and Granting PrivilegesMay 14, 2025 am 12:09 AM

ProperusermanagementinMySQLiscrucialforenhancingsecurityandensuringefficientdatabaseoperation.1)UseCREATEUSERtoaddusers,specifyingconnectionsourcewith@'localhost'or@'%'.2)GrantspecificprivilegeswithGRANT,usingleastprivilegeprincipletominimizerisks.3)

What Factors Influence the Number of Triggers I Can Use in MySQL?What Factors Influence the Number of Triggers I Can Use in MySQL?May 14, 2025 am 12:08 AM

MySQLdoesn'timposeahardlimitontriggers,butpracticalfactorsdeterminetheireffectiveuse:1)Serverconfigurationimpactstriggermanagement;2)Complextriggersincreasesystemload;3)Largertablesslowtriggerperformance;4)Highconcurrencycancausetriggercontention;5)M

MySQL: Is it safe to store BLOB?MySQL: Is it safe to store BLOB?May 14, 2025 am 12:07 AM

Yes,it'ssafetostoreBLOBdatainMySQL,butconsiderthesefactors:1)StorageSpace:BLOBscanconsumesignificantspace,potentiallyincreasingcostsandslowingperformance.2)Performance:LargerrowsizesduetoBLOBsmayslowdownqueries.3)BackupandRecovery:Theseprocessescanbe

MySQL: Adding a user through a PHP web interfaceMySQL: Adding a user through a PHP web interfaceMay 14, 2025 am 12:04 AM

Adding MySQL users through the PHP web interface can use MySQLi extensions. The steps are as follows: 1. Connect to the MySQL database and use the MySQLi extension. 2. Create a user, use the CREATEUSER statement, and use the PASSWORD() function to encrypt the password. 3. Prevent SQL injection and use the mysqli_real_escape_string() function to process user input. 4. Assign permissions to new users and use the GRANT statement.

MySQL: BLOB and other no-sql storage, what are the differences?MySQL: BLOB and other no-sql storage, what are the differences?May 13, 2025 am 12:14 AM

MySQL'sBLOBissuitableforstoringbinarydatawithinarelationaldatabase,whileNoSQLoptionslikeMongoDB,Redis,andCassandraofferflexible,scalablesolutionsforunstructureddata.BLOBissimplerbutcanslowdownperformancewithlargedata;NoSQLprovidesbetterscalabilityand

MySQL Add User: Syntax, Options, and Security Best PracticesMySQL Add User: Syntax, Options, and Security Best PracticesMay 13, 2025 am 12:12 AM

ToaddauserinMySQL,use:CREATEUSER'username'@'host'IDENTIFIEDBY'password';Here'showtodoitsecurely:1)Choosethehostcarefullytocontrolaccess.2)SetresourcelimitswithoptionslikeMAX_QUERIES_PER_HOUR.3)Usestrong,uniquepasswords.4)EnforceSSL/TLSconnectionswith

MySQL: How to avoid String Data Types common mistakes?MySQL: How to avoid String Data Types common mistakes?May 13, 2025 am 12:09 AM

ToavoidcommonmistakeswithstringdatatypesinMySQL,understandstringtypenuances,choosetherighttype,andmanageencodingandcollationsettingseffectively.1)UseCHARforfixed-lengthstrings,VARCHARforvariable-length,andTEXT/BLOBforlargerdata.2)Setcorrectcharacters

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

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

Hot Article

Hot Tools

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software