MERCADOS FINANCIEROS

sábado, 30 de mayo de 2020

FLASHBACK TABLE DROP RENAME

SQL> connect hr     
Enter password: 
Connected.
SQL> 
SQL> drop table hr.prueba;

Table dropped.

SQL> show recyclebin;
ORIGINAL NAME RECYCLEBIN NAME OBJECT TYPE  DROP TIME
---------------- ------------------------------ ------------ -------------------
PRUEBA BIN$pt/fdz3aAjTgVQAAAAAAAQ==$0 TABLE      2020-05-30:10:04:05
SQL> 
SQL> SELECT object_name as recycle_name, original_name, type from recyclebin;


SQL> show recyclebin;
ORIGINAL NAME RECYCLEBIN NAME OBJECT TYPE  DROP TIME
---------------- ------------------------------ ------------ -------------------
PRUEBA BIN$pt/fdz3aAjTgVQAAAAAAAQ==$0 TABLE      2020-05-30:10:04:05
SQL> 
SQL> 

SQL> flashback table hr.prueba to before drop;

SQL> flashback table "BIN$pt/fdz3aAjTgVQAAAAAAAQ==$0" TO BEFORE DROP RENAME TO CAMBIO;

Flashback complete.



SQL> drop table cambio;

Table dropped.

SQL> 
SQL> show recyclebin;
ORIGINAL NAME RECYCLEBIN NAME OBJECT TYPE  DROP TIME
---------------- ------------------------------ ------------ -------------------
CAMBIO BIN$pt/fdz3jAjTgVQAAAAAAAQ==$0 TABLE      2020-05-30:10:12:10
CAMBIO BIN$pt/fdz3hAjTgVQAAAAAAAQ==$0 TABLE      2020-05-30:10:11:39
CAMBIO BIN$pt/fdz3cAjTgVQAAAAAAAQ==$0 TABLE      2020-05-30:10:11:10
SQL> 
SQL> 
SQL> flashback table "BIN$pt/fdz3hAjTgVQAAAAAAAQ==$0" to before drop;

Flashback complete.


SQL> show recyclebin;
ORIGINAL NAME RECYCLEBIN NAME OBJECT TYPE  DROP TIME
---------------- ------------------------------ ------------ -------------------
CAMBIO BIN$pt/fdz3jAjTgVQAAAAAAAQ==$0 TABLE      2020-05-30:10:12:10
CAMBIO BIN$pt/fdz3cAjTgVQAAAAAAAQ==$0 TABLE      2020-05-30:10:11:10
SQL> 
SQL> 
SQL> purge recyclebin;

Recyclebin purged.

SQL> show recyclebin;
SQL> 

PURGAR UN OB JETO DE LA PAPELERA 

SQL> show recyclebin;
ORIGINAL NAME RECYCLEBIN NAME OBJECT TYPE  DROP TIME
---------------- ------------------------------ ------------ -------------------
CAMBIO BIN$sUhShFQCW7XgVQAAAAAAAQ==$0 TABLE      2020-10-09:20:52:48
SQL> exit
Disconnected from Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 - 64bit Production
With the Partitioning, Automatic Storage Management, OLAP, Advanced Analytics
and Real Application Testing options
[oracle@localhost ~]$ sqlplus / as sysdba

SQL*Plus: Release 12.1.0.1.0 Production on Fri Oct 9 20:53:10 2020

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


Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 - 64bit Production
With the Partitioning, Automatic Storage Management, OLAP, Advanced Analytics
and Real Application Testing options

SQL> purge table hr.cambio;

Table purged.

SQL> connect hr/hr;
Connected.
SQL> show recyclebin;
SQL> 

LABORATORIO FLASHBACK QUERY

LABORATORIO FLASHBACK QUERY

select employee_id,salary from hr.employees
AS OF TIMESTAMP
     TO_TIMESTAMP('2020-04-27 20:13:00', 'YYYY-MM-DD HH24:MI:SS')
where employee_id=200

--update hr.employees set salary=5000 where employee_id=200;
commit;

AS OF TIMESTAMP
     TO_TIMESTAMP('2020-04-27 20:15:00', 'YYYY-MM-DD HH24:MI:SS')
where employee_id=200


No hay comentarios: