Postgresql: keep 2 sequences synchronized

Posted by Giovanni Di Milia on Stack Overflow See other posts from Stack Overflow or by Giovanni Di Milia
Published on 2010-03-25T17:03:10Z Indexed on 2010/03/25 17:13 UTC
Read the original article Hit count: 456

Filed under:
|
|

Is there a way to keep 2 sequences synchronized in Postgres?

I mean if I have:

table_A_id_seq = 1
table_B_id_seq = 1

if I execute SELECT nextval('table_A_id_seq'::regclass)

I want that table_B_id_seq takes the same value of table_A_id_seq

and obviously it must be the same on the other side.

I need 2 different sequences because I have to hack some constraints I have in Django (and that I cannot solve there).

© Stack Overflow or respective owner

Related posts about postgresql

Related posts about sequences