Postgresql change auto-increment

How to change postgresql auto-increment database field, similar to
"ALTER TABLE tbl AUTO_INCREMENT = 500" in MsSQL database?
chiabpAsked:
Who is Participating?
 
ivanovnCommented:
You want to set the sequence to a different number?

Check the postgresql sequence documentation at:
http://www.postgresql.org/docs/8.2/interactive/functions-sequence.html

In general you can use the code below to set the value.


-- Set the value of a sequence to 300
SELECT setval('schemaname.sequencename', 300);

Open in new window

0
 
gheistCommented:
Undocomented nonstandard MS SQL feature is not implemented in PostgreSQL and is unlikely to ever be present in any database out there.

0
 
chiabpAuthor Commented:
You mean there is no way for postgresql database to change the auto-increment number? I have search from internet, there is "setval()" function in postgresql, but I not sure how to use it, any ideas?

My purpose just simple to change my auto-number, example from 200 to 300

thank you
0
 
gheistCommented:
There is no documentation for MS SQL AUTO_INCREMENT=int table attribute.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.