How to start a serial id from a custom number (e.g. like 1001)
Hi
I have a simple table called PRODUCT. I want the primary key id starts from 1001 not from 1
this is my table
5 Replies
thanks, but I used this and put it into a sql file then generate it but didn't work. would please explain more
This is probably the best explanation I can find.
https://popsql.com/learn-sql/postgresql/how-to-alter-sequence-in-postgresql
PopSQL
PostgreSQL: Alter Sequence Command - PopSQL
Learn how to use the PostgreSQL 'Reset Sequence' command. If you have auto-incrementing serial ID columns, they typically start at 1. Sequences, managed in their designated tables, store essential details like start values and last values. Use 'Alter Sequence' to change the initial ID number.
thanks again but when I generate or push, this won't work HOW should I implement this?
If you have an SQL client to connect to your db. Try to run it there and then run the SELECT command on it to confirm it was updated. Note that it does not update existing values in the db.