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?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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

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
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
gheistCommented:
There is no documentation for MS SQL AUTO_INCREMENT=int table attribute.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PostgreSQL

From novice to tech pro — start learning today.