dcsimg

Panic SEQuences

March 23, 2009



>>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;

SELECT 'CREATE 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








The Network for Technology Professionals

Search:

About Internet.com

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | E-mail Offers