{"id":36,"date":"2009-03-17T08:27:00","date_gmt":"2009-03-17T06:27:00","guid":{"rendered":"http:\/\/antynet.pl\/index.php\/2009\/03\/17\/oracle-flashback\/"},"modified":"2010-08-25T23:26:53","modified_gmt":"2010-08-25T21:26:53","slug":"oracle-flashback","status":"publish","type":"post","link":"https:\/\/www.antynet.pl\/index.php\/2009\/03\/17\/oracle-flashback\/","title":{"rendered":"ORACLE FLASHBACK"},"content":{"rendered":"<hr \/>\n<div><span style=\"font-weight: bold;\">FLASHBACK DEPEND ON UNDO DATA<\/span><\/p>\n<hr \/>\n<\/div>\n<div><span style=\"font-weight: bold;\">-conditions:<\/span><\/div>\n<div><span style=\"font-weight: bold;\"><span style=\"font-weight: normal;\">UNDO_MANAGEMENT=AUTO<\/span><br \/><\/span><\/div>\n<div>UNDO_RETENTION=900 #(in seconds 900 equal 15min, if value is extended UNDO tablespace will be increased also)<\/div>\n<div>only for DML because FLASHBACK use data directory, but DDL cause ORA-01466<\/div>\n<div>only for DELETE because TRUNCATE are not write in UNDO tablespace<\/div>\n<div><span style=\"font-weight: bold;\">recover delete rows:<\/span><\/div>\n<p>INSERT INTO [table] (SELECT * FROM  [table] AS OF TIMESTAMP TO_TIMESTAMP(&#8217;2008-01-01 10:00:00&#8242;,&#8217;YYYY-MM-DD HH24:MI:SS&#8217;) MINUS SELECT * FROM [table];<span style=\"color: #333333; font-family: Arial; font-size: 11px; line-height: 17px;\"><\/span><\/p>\n<div><span style=\"font-weight: bold;\">recover table:<\/span><\/div>\n<div>FLASHBACK TABLE [table] TO TIMESTAMP TO_TIMESTAMP(&#8217;2008-01-01 10:00:00&#8242;,&#8217;YYYY-MM-DD HH24:MI:SS&#8217;);<\/div>\n<div>SELECT versions_xid FROM [table] VERSIONS BETWEEN TIMESTAMP TO_TIMESTAMP ( '2008-01-01 08:00:00&#8242;,&#8217;YYYY-MM-DD HH24:MI:SS&#8217;) and to_timestamp ( '2008-01-01 08:10:00&#8242;,&#8217;YYYY-MM-DD HH24:MI:SS&#8217;);<\/div>\n<div>SLECT * FROM flashback_transaction_query WHERE xid = HEXTORAW ('[above&#8217;]);<\/div>\n<hr \/>\n<div><span style=\"font-weight: bold;\">FLASHBACK DEPEND ON FLASHBACK LOGS<\/span><\/p>\n<hr \/>\n<\/div>\n<div><\/p>\n<div><span style=\"font-weight: bold;\">&#8211; conditions:<\/span><\/div>\n<div>SELECT log_mode,flashback_on FROM V$DATABASE;<\/div>\n<div>ARCHIVELOG mode is necessary, in parameter LOG_ARCHIVE_DEST_n<\/p>\n<div>DB_RECOVERY_FILE_DEST #init param for flashback logs space<\/p>\n<\/div>\n<p><\/p>\n<div>DB_RECOVERY_FILE_DEST_SIZE #init param for flasback logs size<br \/>DB_FLASHACK_RETENTION_TARGET #init param for flashback log time store<br \/>STARTUP MOUNT<\/p>\n<\/div>\n<\/div>\n<div>ALTER DATABASE FLASHBACK ON<\/div>\n<p><span style=\"font-weight: bold;\">recovery:<\/span><\/div>\n<div>STARTUP MOUNT<\/div>\n<div>FLASHBACK DATABASE TO TIMESTAMP SYSDATE-1 |  TO TIMESTAMP to_timestamp(&#8217;2009-09-28 11:00&#8242;,&#8217;yyyy-mm-dd hh24:mi&#8217;) | TO SCN [scn#];<\/div>\n<div>* ALTER DATABASE OPEN READ ONLY;<br \/>* check data by SELECT command<br \/>* SHUTDOWN IMMEDIATE;<br \/>* STARTUP MOUNT;<br \/>* ALTER DATABASE OPEN RESETLOGS;<\/div>\n<div><span style=\"font-weight: bold;\">futhermore:<\/span><br \/>SELECT estimated_flashback_size FROM v$flashback_database_log; #estimate size for flashback logs in Bytes<br \/>DB_FLASHBACK_RETENTION_TARGET #estimate depends on present load<\/div>\n<p>SELECT oldest_flashback_scn, oldest_flashback_time FROM v$flashback_database_log; #oldest point which recovery is possible <span style=\"font-style: italic;\">(if you want to chec, delete oldest flashback log and oldest point will change)<br \/><\/span>SELECT  * FROM v$flash_recovery_area_usage;<br \/>SELECT * FROM v$recovery_file_dest;<\/p>\n<p>SELECT SCN_TO_TIMESTAMP(10213123) FROM DUAL; <\/p>\n<div>\n<div>\n<hr \/>\n<div><span style=\"font-weight: bold;\">RECYCLEBIN<\/span><\/div>\n<hr \/>\n<p>&#8211; delete table:<br \/>DROP TABLE [table_name]<br \/>&#8211; check &#8222;recyclebin&#8221;<br \/>SHOW RECYCLEBIN<br \/>&#8211; recover<br \/>FLASHBACK TABLE [table_name] TO BEFORE DROP;<br \/>&#8211; delete without &#8222;recyclebin&#8221;<br \/>DROP TABLE [table_name] PURGE;<br \/>&#8211; purge &#8222;recyclebin&#8221;<br \/>PURGE TABLE [table_name];<br \/>PURGE TABLESPACE [ts_name];<br \/>PURGE TABLESPACE [ts_name] USER [user];<br \/>PURGE RECYCLEBIN<br \/>PURGE DBA_RECYCLEBIN;<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>FLASHBACK DEPEND ON UNDO DATA -conditions: UNDO_MANAGEMENT=AUTO UNDO_RETENTION=900 #(in seconds 900 equal 15min, if value is extended UNDO tablespace will be increased also) only for DML because FLASHBACK use data directory, but DDL cause ORA-01466 only for DELETE because TRUNCATE are not write in UNDO tablespace recover delete rows: INSERT INTO [table] (SELECT * FROM [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_et_pb_use_builder":"","_et_pb_old_content":"","_et_gb_content_width":"","footnotes":""},"categories":[80],"tags":[42],"class_list":["post-36","post","type-post","status-publish","format-standard","hentry","category-oracle","tag-oracle-flashback"],"_links":{"self":[{"href":"https:\/\/www.antynet.pl\/index.php\/wp-json\/wp\/v2\/posts\/36","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.antynet.pl\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.antynet.pl\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.antynet.pl\/index.php\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.antynet.pl\/index.php\/wp-json\/wp\/v2\/comments?post=36"}],"version-history":[{"count":2,"href":"https:\/\/www.antynet.pl\/index.php\/wp-json\/wp\/v2\/posts\/36\/revisions"}],"predecessor-version":[{"id":226,"href":"https:\/\/www.antynet.pl\/index.php\/wp-json\/wp\/v2\/posts\/36\/revisions\/226"}],"wp:attachment":[{"href":"https:\/\/www.antynet.pl\/index.php\/wp-json\/wp\/v2\/media?parent=36"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.antynet.pl\/index.php\/wp-json\/wp\/v2\/categories?post=36"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.antynet.pl\/index.php\/wp-json\/wp\/v2\/tags?post=36"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}