Skip to content

Instantly share code, notes, and snippets.

@amirhadadi
amirhadadi / snapshot.sql
Last active January 17, 2017 03:05
Restore Oracle schema to a known state
CREATE OR REPLACE FORCE VIEW V_RESTORABLE_TABLES AS
SELECT table_name tbl from user_tables WHERE
table_name not like 'FRESH%'
AND temporary = 'N'
AND table_name NOT IN ('SNAPSHOT_DATA','SNAPSHOT_TABLE_GROUPS','TABLES_META_DATA')
minus
(select log_table from user_mview_logs)
minus
(select object_name from user_objects where object_type='MATERIALIZED VIEW');