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:

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

Popular posts from this blog

css - SVG using textPath a symbol not rendering in Firefox -

Java 8 + Maven Javadoc plugin: Error fetching URL -

order - Notification for user in user account opencart -