Linked Questions
16 questions linked to/from How to set auto increment primary key in PostgreSQL?
0 votes
1 answer
343 views
Auto Increment in Postgres from Dropwizard Application [duplicate]
I am connecting my dropwizard application with the Postgres db. I am creating tables dynamically at the time of starting the application server. private static void createTableUser(Connection ...
0 votes
0 answers
18 views
To generate Unique Number for multiple users trying to insert at same time while creating new user in Postgresql [duplicate]
I have a situation, where new patients can be created through multiple portals simultaneously. I am working in PostgreSQL DB. Thanks in Advance. VD. Currently we are considering MAX(id) and ...
314 votes
7 answers
368k views
How to add an auto-incrementing primary key to an existing table in PostgreSQL?
I have a PostgreSQL table with existing data. How do I add an auto-incrementing primary key without deleting and re-creating the table?
42 votes
4 answers
77k views
Auto increment table column
Using Postgres, I'm trying to use AUTO_INCREMENT to number my primary key automatically in SQL. However, it gives me an error. CREATE TABLE Staff ( ID INTEGER NOT NULL AUTO_INCREMENT, ...
4 votes
4 answers
3k views
Seeds.rb sets primary key value, results in duplicate key error
In my Rails 4 app, which I am using on Heroku for production, I have set up a seeds.rb file for the initial set of data. As it is critical that a few records have specific primary ids, say in the '...
2 votes
2 answers
3k views
psycopg2 unable to insert into specific columns
I have a postgres database that I am accessing via Python using the psycopg2 library. The table I am attempting to insert into looks like this: ...
1 vote
5 answers
1k views
How to insert a primary key value into a table under race conditions?
We have a code that inserts a new value into the table column that is a primary key. First we are doing select and if this value is not present then we do insert. query = "SELECT AValue from ...
2 votes
1 answer
3k views
Why doesn't PostgreSQL use unsigned integers for IDs? Wouldn't that give twice as many possible records?
According to this documentation, PostgreSQL doesn't support unsigned integers. While I get that it makes the type resolution system less complicated, I don't see how this is practical for let's say ...
1 vote
1 answer
3k views
How to use autogenerated ID in JdbcBatchItemWriter?
I'm using Spring JdbcBatchItemWriter to flush lots of data to a postgres DB. INSERT INTO customer (id, name, zip) VALUES (?,?,?) I only set name + zip as I want the id to be auto generated. But how ...
0 votes
2 answers
2k views
Insert a single variable into a table in PostgreSQL using python
I am trying to insert a single value into a Postgres table with two columns. The first column is an auto-increasing primary key while the second column should be a variable. I have done some research ...
1 vote
1 answer
3k views
Rails - ActiveRecord error on insert into PostgreSql
I have taken over an existing Rails 3.2.9 app and am trying to set it up on my local windows 7 machine, but am getting the following error when trying to register a user: ActiveRecord::...
1 vote
1 answer
2k views
Doctrine increment id after static insertion
So I created an sql script with a lot of data in it that I ran in a postgresql Database. I use the Doctrine2 ORM inside the application to handle the database. The problem I would like to fix is as ...
1 vote
1 answer
976 views
Designing Database to Support Multi-Language
I am attempting to introduce multi-language support into the back end of an application, and trying to figure out a strategy to efficiently implement this into the current schema. I currently have ...
0 votes
2 answers
843 views
How can execute a sequence in JpaRepository?
how can execute a sequence in JpaRepository? and then read the id from the Entity. public interface EmailRepository extends JpaRepository<Email, Long> { } emailService....
1 vote
2 answers
562 views
Is there a working example of Slick 2.0 AutoInc with Postgres?
I am relatively new to Slick and I keep getting the org.postgresql.util.PSQLException: ERROR: null value in column "id" violates not-null constraint message. I found plenty of examples with Slick 1.x ...
0 votes
2 answers
430 views
JBOSS and JPA query- Adding a new customer
I have been battling with this for the last few days and am at the end of my tether. Please can someone help me figure out where/why I am going wrong. Thank you very much indeed. Here is my story: I ...