search
HomeDatabaseMysql TutorialORACLE重装之后恢复数据库,相当于sqlserver的附加数据库

在开发机器上经常会遇到重装系统的问题,重装之前如果ORACLE没有及时备份的话重装之后就纠结了,数据还原很头疼。 各种娘中只能找到一些ORACLE安装与重装系统前目录相同的解决办法,目录不同就没招了。 我用的是oracle11G。老版的应该相似。 经过我的尝试,

在开发机器上经常会遇到重装系统的问题,重装之前如果ORACLE没有及时备份的话重装之后就纠结了,数据还原很头疼。

各种娘中只能找到一些ORACLE安装与重装系统前目录相同的解决办法,目录不同就没招了。

我用的是oracle11G。老版的应该相似。

经过我的尝试,找到了几个关键点,现在分享出来。

1、控制文件CONTROL01.CTL

oracle数据库的控件文件有两个,一个是在oradata\oradb中,名称为CONTROL01.CTL

另外一个是在flash_recovery_area\SDMS_DEMO,名称为CONTROL01.CTL 

控件文件也可能是CONTROL02.CTL 或CONTROL03.CTL

2、控制文件中的datafile,tempfile,logfile

原数据库中的文件路径如果和重装后的路径不一致,需要将这些路径全部修改之后就可以了,具体步骤如下:

一:重新创建oracle数据库后手动关闭oracle所有服务

二:将oradata中新创建的数据库目录改名,d:\app\user\oradata\oradb,改为d:\app\user\oradata\oradb_new

三:将原来的数据库目录复制到该目录下,复制后的结果是oradata中有d:\app\user\oradata\oradb_new和d:\app\user\oradata\oradb两个目录

d:\app\user\oradata\oradb是重装之前数据库的数据文件夹。

四:启动各项oracle服务

五:用sqlplus /nolog命令进入oracle命令符

六:用connect sys/change_on_install as sysdba;命令获得系统管理权限并登录。

七:用select instance_name from v$instance;确认当前的数据库实例是否正确,如果不是oradb需要使用 set oracle_sid来修改默认的oracle实例(没记错的话应该是这个命令可以问度娘查一下)。

八:将d:\app\user\oradata\oradb\CONTROL02.CTL控制文件复制到d:\app\user\flash_recovery_area\oradb中,替换目录中原有的控制文件,注意:名称不一样的话改一下名字。

九:使用startup nomount用无装载模式启动数据库。

十: 设置数据库为装载模式:alter database mount;

十一:查看数据文件清单:select name from v$datafile;

查看临时文件清单:select name from v$tempfile;
查看日志文件清单:select * from v$logfile;

会看到如下结果:

E:\APP\USER\ORADATA\ORADB\SYSTEM01.DBF
E:\APP\USER\ORADATA\ORADB\SYSAUX01.DBF
E:\APP\USER\ORADATA\ORADB\UNDOTBS01.DBF
E:\APP\USER\ORADATA\ORADB\USERS01.DBF
E:\APP\USER\ORADATA\ORADB\SDMS_DATA01.DBF

十二:修改数据文件路径,依次执行如下命令:

SQL> alter database rename file 'E:\APP\USER\ORADATA\ORADB\SYSTEM01.DBF' to 'D:\APP\USER\ORADATA\ORADB\SYSTEM01.DBF'

注意日志文件修改的时候有点纠结 文件名是redo01,因为oracle默认为大写,我看成了red001,一直修改不成,另外一个,如果用select * from v$logfile;看到的只有一条日志文件,建议把原数据库中的几个都修改一下。

SQL> alter database rename file 'E:\APP\USER\ORADATA\ORADB\REDO03.LOG' to'D:\APP\USER\ORADATA\ORADB\REDO03.LOG';

十三:启动数据库:alter database open;

好了,现在可以用客户端连接这个数据库了。

 

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

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools