Move Sequence to Different Schema

Moderator: NorbertKrupa

Post Reply
sarah
Intermediate
Intermediate
Posts: 77
Joined: Mon Aug 27, 2012 1:34 pm

Move Sequence to Different Schema

Post by sarah » Wed Feb 19, 2014 1:37 pm

Howdy,

How can I move a sequence from one schema to another without dropping and re-creating it?

Thanks!
Have a GREAT day!

User avatar
JimKnicely
Site Admin
Site Admin
Posts: 1825
Joined: Sat Jan 21, 2012 4:58 am
Contact:

Re: Move Sequence to Different Schema

Post by JimKnicely » Wed Feb 19, 2014 3:28 pm

Use the ALTER SEQUENCE SET SCHEMA command.

Example:

Code: Select all

dbadmin=> create sequence jim_seq;
CREATE SEQUENCE
dbadmin=> \ds jim_seq;
                                           List of Sequences
 Schema | Sequence | CurrentValue | IncrementBy | Minimum |       Maximum       | AllowCycle | Comment 
--------+----------+--------------+-------------+---------+---------------------+------------+---------
 public | jim_seq  |            0 |           1 |       1 | 9223372036854775807 | f          | 
(1 row)

dbadmin=> create schema jim;
CREATE SCHEMA

dbadmin=> alter sequence jim_seq set schema jim;
ALTER SEQUENCE

dbadmin=> \ds jim_seq;
                                           List of Sequences
 Schema | Sequence | CurrentValue | IncrementBy | Minimum |       Maximum       | AllowCycle | Comment 
--------+----------+--------------+-------------+---------+---------------------+------------+---------
 jim    | jim_seq  |            0 |           1 |       1 | 9223372036854775807 | f          | 
(1 row)
Jim Knicely

Image

Note: I work for Vertica. My views, opinions, and thoughts expressed here do not represent those of my employer.

Post Reply

Return to “New to Vertica Database Administration”