Useful shortcuts for vi editor

Showing posts with label undo. Show all posts
Showing posts with label undo. Show all posts

Friday, 30 March 2018

How to do CTAS in Oracle?

CTAS stands for Create Table As Select

e.g.
SQL>
CREATE TABLE HR.EMPLOYEES_NEW
AS
   SELECT * FROM HR.EMPLOYEES;

-> By default, only "NOT_NULL" constraints copy to new table (HR.EMPLOYEES_NEW) if it has (HR.EMPLOYEES). (PK, FK, index, etc. does not copy)

CTAS is faster because UNDO and REDO data does not generate. (It use NOLOGGING AND PARALEL methods)

Friday, 21 April 2017

How to restore database object such as package body via flashback?

Note that below SQL gets output if it is still in UNDO tablespace.
SQL> 
SELECT text  FROM all_source
       AS OF TIMESTAMP TO_TIMESTAMP ('21-04-2017 14:30:00', 'DD-MM-YYYY HH24:MI:SS')
 WHERE name = 'PRG_BODY_ALPER' 
AND TYPE = 'PACKAGE BODY';

for DBA: dba_source table

Related: https://ozsoyler.blogspot.com/2016/12/how-to-rollback-committed-data-from.html