sequence postgresql 1

sequence postgresql

# Get all sequences
SELECT c.relname FROM pg_class c WHERE c.relkind = 'S';

# Get last value of a sequence
SELECT last_value FROM test_id_seq;

Here is what the above code is Doing:
1. Get the name of the sequence.
2. Get the last value of the sequence.
3. Get the next value of the sequence.
4. Set the next value of the sequence.
5. Get the last value of the sequence.

Similar Posts