postgresql - Rename nextval('...') in Postgres -
i had table called pivot_device_user , had sequence on id not null default nextval('pivot_device_user_id_seq'::regclass).
then decided rename table pivot_box_user, nextval(...) still nextval('pivot_device_user_id_seq'::regclass).
i'd change nextval('pivot_box_user_id_seq'::regclass). how do this?
first must understand serial is:
- safely , cleanly rename tables use serial primary key columns in postgres?
- auto increment sql function
the column default not stored text literal. see human-readable text representation: nextval('pivot_device_user_id_seq'::regclass)
'pivot_device_user_id_seq'::regclass resolved oid internally (regclass precise) - oid of underlying sequence - , that's what's stored (early binding). if rename sequence, oid remains unchanged. need rename sequence:
alter sequence pivot_device_user_id_seq rename pivot_box_user_id_seq; check success with:
select pg_get_serial_sequence('pivot_box_user', 'id'); related:
Comments
Post a Comment