Free Newsletters:
DatabaseDaily  
Database Journal
Search Database Journal:
 
MS SQL Oracle DB2 Access MySQL PostgreSQL Sybase PHP SQL Etc SQL Scripts & Samples Links Database Forum DBA Videos
internet.com

» Database Journal Home
» DBA Videos
» Database Articles
» Database Tutorials
MS SQL
Oracle
MS Access
MySQL
DB2
» RESOURCES
Database Tools
SQL Scripts & Samples
Links
» Database Forum
» DBA Jobs
» Sitemap

News Via RSS Feed



follow us on Twitter

Marketplace Partners
Be a Marketplace Partner

internet.commerce
Be a Commerce Partner


















Mariposa Bot Shipped With Vodafone Smartphone

IT Job Market Heating Up: Report

Bing Makes Strides But Momentum Stalls

internet.com
IT
Developer
Internet News
Small Business
Personal Technology

Search internet.com
Advertise
Corporate Info
Newsletters
Tech Jobs
E-mail Offers


Database Journal | DBA Support | SQLCourse | SQLCourse2







Market Data Analyst - Perl - Python - C++ (IL)
Next Step Systems
US-IL-Chicago

Justtechjobs.com Post A Job | Post A Resume

Featured Database Articles

SQL Scripts & Samples

March 23, 2009

Panic SEQuences



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



Tools:
Add databasejournal.com to your favorites
Add databasejournal.com to your browser search box
IE 7 | Firefox 2.0 | Firefox 1.5.x
Receive news via our XML/RSS feed

SQL Scripts & Samples Archives








Latest Forum Threads
SQL Scripts & Samples Forum
Topic By Replies Updated
Hello, can anyone help?? terryammon 1 February 7th, 07:39 PM
Question on adding a count to an existing query without effecting original result nelson 2 January 26th, 04:08 PM
search substring (same format) from one column nuonuo 0 January 25th, 11:10 PM
uid find in OID cmontr 1 September 24th, 09:05 AM









The Network for Technology Professionals

Search:

About Internet.com

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