Leo
Leo

Reputation: 902

How to change sequence using SQL Query

I want to change some data in a table with _id_seq suffix with this sql query:

UPDATE user_custom_fields_id_seq SET last_value = 1000;

but I get the following error:

ERROR: cannot change sequence "user_custom_fields_id_seq"

Is there anyway to bypass this error by using just SQL?

Upvotes: 9

Views: 3851

Answers (1)

krokodilko
krokodilko

Reputation: 36097

Use ATER SEQUENCE command:

ALTER SEQUENCE user_custom_fields_id_seq
    RESTART WITH 1000;

user_custom_fields_id_seq is not a table, it is a sequence.

Upvotes: 17

Related Questions