In PostgreSQL I have table comments with primary key comment_id (VARCHAR of length 4). I have a form to insert a comment. How to get my Java Servlet to increment comment_id for each INSERT (0001 to 0002)?
In PostgreSQL I have table comments with primary key comment_id ( VARCHAR of length
Share
You don’t want to use a VARCHAR for your id column. In postgres you can create a sequence and then get the next value of that sequence for each insert.
here are the docs
Basically, you do something like
Then, when you insert you do something like