search
HomeDatabaseMysql TutorialOracle用delete命令删除数据恢复

操作的数据库为Oracle 10g , 之前删除方式为delete 不晓得trancate好使不,究竟是哪个词其实对我们来说并不是最重要的,重要的是

同事找回时操作的数据库为Oracle 10g , 之前删除方式为delete 不晓得trancate好使不。

SCN(系统改变号),它的英文全拼为:System Change Number ,它是数据库中非常重要的一个数据结构。

SCN提供了Oracle的内部时钟机制,可被看作逻辑时钟,这对于恢复操作是至关重要的。

注释:Oracle 仅根据 SCN 执行恢复。

它定义了数据库在某个确切时刻提交的版本。在事物提交时,它被赋予一个唯一的标示事物的SCN 。一些人认为 SCN 是指, System Commit Number ,而通常 SCN 在提交时才变化,,所以很多情况下,这两个名词经常被交替使用。

究竟是哪个词其实对我们来说并不是最重要的,重要的是我们知道 SCN 是 Oracle 内部的时钟机制, Oracle 通过 SCN 来维护数据库的一致性,并通过SCN 实施 Oracle 至关重要的恢复机制。

具体执行流程我们可从以下几个示例图中体会;

1.原表记录 $ sqlplus eygle/eygle

SQL*Plus: Release 10.1.0.2.0 - Production on Wed Mar 30 08:52:04 2005

Copyright (c) 1982, 2004, Oracle. All rights reserved.

Connected to:

Oracle Database 10g Enterprise Edition Release 10.1.0.2.0 - 64bit Production

With the Partitioning, OLAP and Data Mining options

SQL>select count(*) from t1;

COUNT(*)

----------

9318

2.误删除所有记录

并且提交更改。

SQL>delete from t1;

9318 rows deleted.

SQL>commit;

Commit complete.

SQL>select count(*) from t1;

COUNT(*)

----------

0

3.获得当前SCN

如果能够确切知道删除之前SCN最好,如果不知道,可以进行闪回查询尝试.

SQL>select dbms_flashback.get_system_change_number from dual;

GET_SYSTEM_CHANGE_NUMBER

------------------------

10671006

SQL>select count(*) from t1 as of scn 10671000;

COUNT(*)

----------

0

SQL>select count(*) from t1 as of scn 10670000;

COUNT(*)

----------

9318

我们看到在SCN=10670000时,数据都在。

4.恢复数据.

SQL>insert into t1 select * from t1 as of scn 10670000;

9318 rows created.

SQL>commit;

Commit complete.

SQL>select count(*) from t1;

COUNT(*)

----------

9318

文章2

误删数据后的还原

select timestamp_to_scn(to_timestamp('2009-03-13 09:00:00','YYYY-MM-DD HH:MI:SS')) from dual;

结果:13526973

将删除时间转换为scn

select * from reportinfo

AS OF SCN 13526973

将reportinfo表中的scn点的数据取出

然后可以根据这个数据进行还原操作

create table reporttest as select * from reportinfo where 1=0;

insert into reporttest select * from reportinfo AS OF SCN 13526973;

--上面两句应该可以合成一句

--create table reporttest as select * from reportinfo AS OF SCN 13526973;

这是reporttest表中就是scn点的reportinfo数据.处理即可

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
How do you alter a table in MySQL using the ALTER TABLE statement?How do you alter a table in MySQL using the ALTER TABLE statement?Mar 19, 2025 pm 03:51 PM

The article discusses using MySQL's ALTER TABLE statement to modify tables, including adding/dropping columns, renaming tables/columns, and changing column data types.

How do I configure SSL/TLS encryption for MySQL connections?How do I configure SSL/TLS encryption for MySQL connections?Mar 18, 2025 pm 12:01 PM

Article discusses configuring SSL/TLS encryption for MySQL, including certificate generation and verification. Main issue is using self-signed certificates' security implications.[Character count: 159]

How do you handle large datasets in MySQL?How do you handle large datasets in MySQL?Mar 21, 2025 pm 12:15 PM

Article discusses strategies for handling large datasets in MySQL, including partitioning, sharding, indexing, and query optimization.

What are some popular MySQL GUI tools (e.g., MySQL Workbench, phpMyAdmin)?What are some popular MySQL GUI tools (e.g., MySQL Workbench, phpMyAdmin)?Mar 21, 2025 pm 06:28 PM

Article discusses popular MySQL GUI tools like MySQL Workbench and phpMyAdmin, comparing their features and suitability for beginners and advanced users.[159 characters]

How do you drop a table in MySQL using the DROP TABLE statement?How do you drop a table in MySQL using the DROP TABLE statement?Mar 19, 2025 pm 03:52 PM

The article discusses dropping tables in MySQL using the DROP TABLE statement, emphasizing precautions and risks. It highlights that the action is irreversible without backups, detailing recovery methods and potential production environment hazards.

How do you represent relationships using foreign keys?How do you represent relationships using foreign keys?Mar 19, 2025 pm 03:48 PM

Article discusses using foreign keys to represent relationships in databases, focusing on best practices, data integrity, and common pitfalls to avoid.

How do you create indexes on JSON columns?How do you create indexes on JSON columns?Mar 21, 2025 pm 12:13 PM

The article discusses creating indexes on JSON columns in various databases like PostgreSQL, MySQL, and MongoDB to enhance query performance. It explains the syntax and benefits of indexing specific JSON paths, and lists supported database systems.

How do I secure MySQL against common vulnerabilities (SQL injection, brute-force attacks)?How do I secure MySQL against common vulnerabilities (SQL injection, brute-force attacks)?Mar 18, 2025 pm 12:00 PM

Article discusses securing MySQL against SQL injection and brute-force attacks using prepared statements, input validation, and strong password policies.(159 characters)

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 Article

Hot Tools

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools

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

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor