Panic SEQuences | Database Journal

Panic SEQuences

Mar 23, 2009
1 minute read

>>Script Language and Platform: Oracle

This script will generate all sequences in the database.

We run this script on weekly base.

Author: Yakov Shlafman

set serveroutput off
set lines 200 trimspool on pages 1000
set pagesize 0
set recsep off
col “–CMD–” for a60
set recsep off trimspool on
BREAK ON OWNER;
BREAK ON SEQUENCE_NAME;
SELECTCREATE SEQUENCE’||CHR(10)||CHR(9)||CHR(9)
||SEQUENCE_OWNER||’.’||SEQUENCE_NAME||CHR(10)||CHR(9)||CHR(9)
||’INCREMENT BY ‘||INCREMENT_BY||CHR(10)||CHR(9)||CHR(9)
||DECODE(MIN_VALUE
, -99999999999999999999999999,’NOMINVALUE’||CHR(10)||CHR(9)||CHR(9),
‘MINVALUE ‘||MIN_VALUE||CHR(10)||CHR(9)||CHR(9))
||DECODE(MAX_VALUE
, 999999999999999999999999999,’NOMAXVALUE’||CHR(10)||CHR(9)||CHR(9),
‘MAXVALUE ‘||MAX_VALUE||CHR(10)||CHR(9)||CHR(9))
||’START WITH ‘||LAST_NUMBER||CHR(10)||CHR(9)||CHR(9)
||DECODE(CYCLE_FLAG
, ‘Y’, ‘CYCLE’||CHR(10)||CHR(9)||CHR(9)
, ‘N’, ‘NOCYCLE’||CHR(10)||CHR(9)||CHR(9))
||DECODE(CACHE_SIZE
, 0 , ‘NOCACHE ‘||CHR(10)||CHR(9)||CHR(9)
, ‘CACHE ‘||CACHE_SIZE||CHR(10)||CHR(9)||CHR(9))
||DECODE(ORDER_FLAG, ‘N’, ‘NOORDER ‘,’ORDER ‘)||CHR(10)||’;’
—
“–CMD–”
FROM
ALL_SEQUENCES
WHERE
SEQUENCE_OWNER NOT IN (‘SYS’, ‘SYSTEM’)
;
———————————
— Output RESULTS (Sample)
———————————
CREATE SEQUENCE
KOSHKA.N1
INCREMENT BY 50
MINVALUE 1
MAXVALUE 30000
START WITH 2510
NOCYCLE
CACHE 30
ORDER
;
CREATE SEQUENCE
NORTPA.SEQ1
INCREMENT BY 1
MINVALUE 1
NOMAXVALUE
START WITH 100
NOCYCLE
NOCACHE
ORDER
;
CREATE SEQUENCE
NORTPA.SEQ12
INCREMENT BY 1
MINVALUE 1
MAXVALUE 4294967295
START WITH 1
NOCYCLE
NOCACHE
NOORDER
;
CREATE SEQUENCE
TRIKTR.SEQ15
INCREMENT BY 1
MINVALUE -2147483647
MAXVALUE 2147483647
START WITH 1
NOCYCLE
NOCACHE
NOORDER
;
CREATE SEQUENCE
TRIKTR.TEST_I1D225
INCREMENT BY 50
MINVALUE 1
MAXVALUE 30000
START WITH 400
NOCYCLE
NOCACHE
ORDER
;
CREATE SEQUENCE
WOFTAK.TEST_ID232
INCREMENT BY 50
MINVALUE 1
MAXVALUE 30000
START WITH 100
NOCYCLE
NOCACHE
ORDER
;
CREATE SEQUENCE
WOFTAK.TEST_ID71232
INCREMENT BY 50
MINVALUE 1
MAXVALUE 30000
START WITH 100
NOCYCLE
CACHE 107
ORDER
;



Disclaimer:
We hope that the information on these script pages is
valuable to you. Your use of the information contained in these pages,
however, is at your sole risk. All information on these pages is provided
“as -is”, without any warranty, whether express or implied, of its accuracy,
completeness, or fitness for a particular purpose…

Disclaimer Continued

Back to Database Journal Home

Database Journal Logo

DatabaseJournal.com publishes relevant, up-to-date and pragmatic articles on the use of database hardware and management tools and serves as a forum for professional knowledge about proprietary, open source and cloud-based databases--foundational technology for all IT systems. We publish insightful articles about new products, best practices and trends; readers help each other out on various database questions and problems. Database management systems (DBMS) and database security processes are also key areas of focus at DatabaseJournal.com.

Property of TechnologyAdvice. © 2026 TechnologyAdvice. All Rights Reserved

Advertiser Disclosure: Some of the products that appear on this site are from companies from which TechnologyAdvice receives compensation. This compensation may impact how and where products appear on this site including, for example, the order in which they appear. TechnologyAdvice does not include all companies or all types of products available in the marketplace.