Quantcast
Channel: APEX-AT-WORK by Tobias Arnhold
Viewing all articles
Browse latest Browse all 177

Migrate Sequences

$
0
0
During one of my projects I had an issue when I copied the DDL from my test environment into my productive system. Unfortunately I needed some of the test data in the prod system as well. For that I had to migrate most of the sequences starting with their last number. SQL Developer created those sequences starting with 1. This simple code fixed my issue.

select 'DROP SEQUENCE "'||SEQUENCE_NAME||'";' ||
' CREATE SEQUENCE "'||SEQUENCE_NAME||'"' ||
' MINVALUE 1 MAXVALUE 999999999999999999999999999' ||
' INCREMENT BY 1 START WITH ' || to_char(last_number+1) ||
' NOCACHE NOORDER NOCYCLE ; ' as seq_code
from all_sequences
where sequence_owner = '#SCHEMA_NAME#';
Cheers Tobias

Viewing all articles
Browse latest Browse all 177

Trending Articles