Skip to content

Generate Drop Sequence Statements (drop_sequence.gen)

This generator script creates DROP SEQUENCE statements for sequences matching the specified criteria. It excludes system schemas to prevent accidental drops of critical sequences.

rem drop_sequence.gen
rem
select 'drop sequence ' || sequence_owner || '.' || sequence_name || ';'
from sys.dba_sequences
where sequence_owner like upper('&owner')
and sequence_name like upper('&sequence_name')
and sequence_owner not in ('SYS','SYSTEM','MDSYS','CTXSYS','XDB','ORDDATA','APEX_040200')
order by sequence_owner, sequence_name
/
-- Basic usage
@drop_sequence.gen
-- When prompted, enter:
-- owner: Schema owner pattern (use % for wildcard)
-- sequence_name: Sequence name pattern (use % for wildcard)

The script prompts for:

  • &owner - Schema owner pattern (use % for wildcard)
  • &sequence_name - Sequence name pattern (use % for wildcard)
SELECT ANY DICTIONARY
-- OR --
SELECT ON DBA_SEQUENCES
drop sequence HR.EMPLOYEES_SEQ;
drop sequence HR.DEPARTMENTS_SEQ;
drop sequence SCOTT.TEST_SEQ;
  • System Schema Protection: Excludes critical system schemas
  • Pattern Matching: Use wildcards to match multiple sequences
  • Clean Output: Simple DROP SEQUENCE statements
  • Sorted Results: Ordered by owner and sequence name

Drop All Sequences in Schema

@drop_sequence.gen
-- Enter: SCOTT for owner, % for sequence_name

Drop Sequences with Pattern

@drop_sequence.gen
-- Enter: % for owner, %_OLD for sequence_name