COMP1638: Database Management and Administration Lab 8 Flashback Technologies

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 5

COMP1638: Database Management and Administration

Lab 8
Flashback Technologies
Overview

In this lab you will perform data recovery using flashback technology. First you will use Flashback Drop
functionality to recover a table after it’s been accidently dropped and then you will use Flashback Table
functionality to recover from unwanted committed transactions.

Lab 8.1: Recover table with Flashback Drop functionality.

1. Open SQL*Plus window. Connect as AGREEN/oracle.

2. Drop table books_main with the following command:

drop table books_main;

3. Try to select data from that table by performing:

SELECT * from books_main;

You should get an error that the table doesn’t exist

4. Now you need to verify that the table books_main has been dropped by querying the data dictionary.

Question 1: What SQL command do you need to execute to check the existence of the table books_main in
the agreen schema using dba_tables data dictionary view? Execute the command in SQL*Plus. Make a
screen-shot of the result and explain.

a) Execute your SQL command in SQL*Plus.

5. In SQL Developer to AGREEN connection.

a) Click on Recycle Bin button and select AGREEN schema.


b) Also you could check the content of the Recycle Bin in SQL*Plus:

Notice the system name that was given to the dropped table

6. Try to query dropped table’s data using it’s bin name:

SELECT * from “BIN$ ……”;

7. Recover table books_main using Flashback Drop functionality in SQL*PLus (use the lecture notes to
guide you).

Question 2: What SQL command do you need to execute to recover completely table books_main after it has
been dropped accidently? Explain how this feature is implemented.

8. After the flashback complete, navigate to the list of tables for AGREEN in EM and check the restored table.
9. Now navigate to agreen schema in SQL Developer and check the Recycle Bin again.

Lab 8.2: Recover data in the table with Flashback Table functionality.

1. In SQL*Plus window (still connected as AGREEN /oracle) check the current records:

SELECT * FROM books_main;

2. Insert a new record into the books_main table with the following data:

Title: Python programming


Code: 12345
Reorder_threshold: 2
Price: 25.60

Write INSERT command and COMMIT it.

3. Now you are going to simulate a problem: you had to update the title of the book to ‘Facebook for Dummies’
in the last record, but forgot to put ‘where’ condition into your update command and therefore updated all
records and committed that transaction :

a) In SQL*Plus window connected as agreen execute following command:

update books_main

set title=’Facebook for Dummies’;

b) Commit your transaction.


4. Now you realised that you made a mistake, try to roll back the changes using ROLLBACK command.

Question 3: What is the result of the ROLLBACK command? Explain why it didn’t succeed; discuss the database
principles that are implemented here to provide this behaviour.

5. Now you have to recover the table data from that erroneous transaction.

a) In SQL Developer navigate to all tables for agreen and double click on BOOKS_MAIN. Click on tab
Flashback. The results window will show all historic information on operations performed on that table
including the SCN numbers. Your view might be different from the screen-shot below:

b) Find the Update operation that you want to recover and it’s VERSION_STARTSCN

c) In SQL*Plus recover that erroneous transaction with the help of FLASHBACK TABLE command using
the correct SCN

The error tells you that the Flashback cannot be performed, because ROW MOVEMNT has not been
enabled.

d) Enable Row Movement on the table agree.books_main and perform FLASHBACK:


e) Now check the data in books_main table to ensure the data has been recovered.

Deliverables:
For formative assessment, please answer the following questions:
Question 1: What SQL command do you need to execute to check the existence of the table books_main
in the agreen schema using dba_tables data dictionary view? Make a screen-shot of the result and
explain.

Question 2: What SQL command do you need to execute to recover completely table books_main after it
has been dropped accidently? Explain how this feature is implemented.

Question 3: What is the result of the ROLLBACK command? Explain why it didn’t succeed; discuss the
database principles that are implemented here to provide this behaviour.

You might also like