search
HomeDatabaseOracleThree methods to quickly recover accidentally deleted Oracle database

This article brings you relevant knowledge about Oracle, which mainly introduces how to quickly delete data in the Oracle database without considering the full database backup and archive log utilization. Let’s take a look at the related issues of recovering data. I hope it will be helpful to everyone.

Three methods to quickly recover accidentally deleted Oracle database

Recommended tutorial: "Oracle Video Tutorial"

Deleting data in the oracle database by mistake without considering all How to quickly restore data when using database backup and archive logs?

The following are 3 methods.

1. Use the flashback method provided by Oracle for data recovery, which is suitable for delete deletion method

First obtain the time point of deleted data:

select * from v$sql where sql_text like '%table_name%' ;
1

According to the sql_text content in the result, find the delete time point corresponding to the delete execution statement, and execute the following statement to query the deleted data.

select * from table_name as of timestamp to_timestamp(‘删除时间点’,‘yyyy-mm-dd hh24:mi:ss’)
where (删除时的条件)
12

After checking that the data is correct, perform the following operations to insert the data back into the original table. Note that the primary key is not repeated

insert into table_name
select * from from table_name as of timestamp to_timestamp(‘删除时间点’,‘yyyy-mm-dd hh24:mi:ss’)
where (删除时的条件)
123

2. Use the oracle virtual recycle bin function

The principle is because the oracle database will delete the information when deleting the table It is stored in a virtual recycle bin instead of being emptied directly. In this state, the database marks the table as can be copied, so the block has not been reused. Data can still be recovered before . This method is mostly used for drop deletion.

First query the user_table view to find the deleted table:

select table_name,dropped from user_tables;
select object_name,original_name,type,droptime from user_recyclebin;
12

Note at this time, object_name and original_name It is the name of the table stored in the recycle bin and the name of the originally deleted table. If the table name has not been renamed, you can restore it through the following statement:

flashback table original_name to before drop;
1

If you do not know the source table name, or you need to rename the new If the data is stored in the table name of the recycle bin, it can be restored through object_name in the recycle bin. The command is as follows:

flashback table object_name to before drop new_table_name;
1

3. Use the flashback function of the oracle database to restore the database to A certain state in the past

Note that this is whole database recovery, the specific syntax is as follows:

SQL>alter database flashback on
SQL>flashback database to scn SCNNO;
SQL>flashback database to timestamp to_timestamp(‘frombyte 2021-09-02 23:59:59’,‘yyyy-mm-dd hh24:mi:ss’);
123

4. Completely delete data

If we determine the data that needs to be deleted and do not want to occupy space unnecessarily, we can use the following three methods:

  1. Truncate using the truncate method. (Data recovery is not possible)
  2. Add the purge option when dropping: drop table table_name purge
  3. Make it permanent by deleting the recyclebin area Delete the table,drop table table_name cascade constraints purge table table_name;

##5. About emptying the recycle bin

  1. Delete the current user’s recycle bin

    purge recyclebin;

  2. Delete all users’ data in the recycle bin

    purge dba_recyclebin;

  3. ## Recommended tutorial: "
Oracle Video Tutorial

"

The above is the detailed content of Three methods to quickly recover accidentally deleted Oracle database. For more information, please follow other related articles on the PHP Chinese website!

Statement
This article is reproduced at:CSDN. If there is any infringement, please contact admin@php.cn delete
oracle怎么查询所有索引oracle怎么查询所有索引May 13, 2022 pm 05:23 PM

方法:1、利用“select*from user_indexes where table_name=表名”语句查询表中索引;2、利用“select*from all_indexes where table_name=表名”语句查询所有索引。

什么是oracle asm什么是oracle asmApr 18, 2022 pm 04:16 PM

oracle asm指的是“自动存储管理”,是一种卷管理器,可自动管理磁盘组并提供有效的数据冗余功能;它是做为单独的Oracle实例实施和部署。asm的优势:1、配置简单、可最大化推动数据库合并的存储资源利用;2、支持BIGFILE文件等。

oracle全角怎么转半角oracle全角怎么转半角May 13, 2022 pm 03:21 PM

在oracle中,可以利用“TO_SINGLE_BYTE(String)”将全角转换为半角;“TO_SINGLE_BYTE”函数可以将参数中所有多字节字符都替换为等价的单字节字符,只有当数据库字符集同时包含多字节和单字节字符的时候有效。

Oracle怎么查询端口号Oracle怎么查询端口号May 13, 2022 am 10:10 AM

在Oracle中,可利用lsnrctl命令查询端口号,该命令是Oracle的监听命令;在启动、关闭或重启oracle监听器之前可使用该命令检查oracle监听器的状态,语法为“lsnrctl status”,结果PORT后的内容就是端口号。

oracle怎么删除sequenceoracle怎么删除sequenceMay 13, 2022 pm 03:35 PM

在oracle中,可以利用“drop sequence sequence名”来删除sequence;sequence是自动增加数字序列的意思,也就是序列号,序列号自动增加不能重置,因此需要利用drop sequence语句来删除序列。

oracle怎么查询数据类型oracle怎么查询数据类型May 13, 2022 pm 04:19 PM

在oracle中,可以利用“select ... From all_tab_columns where table_name=upper('表名') AND owner=upper('数据库登录用户名');”语句查询数据库表的数据类型。

oracle查询怎么不区分大小写oracle查询怎么不区分大小写May 10, 2022 pm 05:45 PM

方法:1、利用“LOWER(字段值)”将字段转为小写,或者利用“UPPER(字段值)”将字段转为大写;2、利用“REGEXP_LIKE(字符串,正则表达式,'i')”,当参数设置为“i”时,说明进行匹配不区分大小写。

Oracle怎么修改sessionOracle怎么修改sessionMay 13, 2022 pm 05:06 PM

方法:1、利用“alter system set sessions=修改后的数值 scope=spfile”语句修改session参数;2、修改参数之后利用“shutdown immediate – startup”语句重启服务器即可生效。

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

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Tools

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development 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

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.