Howdy,
How can I move a sequence from one schema to another without dropping and re-creating it?
Thanks!
Move Sequence to Different Schema
Moderator: NorbertKrupa
Move Sequence to Different Schema
Have a GREAT day!
- JimKnicely
- Site Admin
- Posts: 1825
- Joined: Sat Jan 21, 2012 4:58 am
- Contact:
Re: Move Sequence to Different Schema
Use the ALTER SEQUENCE SET SCHEMA command.
Example:
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
Note: I work for Vertica. My views, opinions, and thoughts expressed here do not represent those of my employer.
Note: I work for Vertica. My views, opinions, and thoughts expressed here do not represent those of my employer.