Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9151601
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T11:50:35+00:00 2026-06-17T11:50:35+00:00

I have defined a serial PRIMARY KEY , like this: CREATE TABLE auth_event( id

  • 0

I have defined a serial PRIMARY KEY, like this:

CREATE TABLE auth_event(
    id serial PRIMARY KEY,
    time_stamp TIMESTAMP,
    client_ip VARCHAR(512),
    user_id INTEGER REFERENCES auth_user (id) ON DELETE CASCADE,
    origin VARCHAR(512),
    description TEXT
);

The dump that I am importing has explicit values for the serial field, like this:

INSERT INTO "auth_event" VALUES(6,'2012-12-03 21:50:49','127.0.0.1',181,'auth','User 181 Logged-in');
INSERT INTO "auth_event" VALUES(7,'2012-12-04 07:37:43','127.0.0.1',181,'auth','User 181 Logged-in');
INSERT INTO "auth_event" VALUES(8,'2012-12-05 11:42:28','127.0.0.1',181,'auth','User 181 Logged-in');
INSERT INTO "auth_event" VALUES(9,'2012-12-07 08:01:59','127.0.0.1',181,'auth','User 181 Logged-in');
INSERT INTO "auth_event" VALUES(10,'2012-12-07 16:32:58','127.0.0.1',181,'auth','User 181 Logged-in');
INSERT INTO "auth_event" VALUES(11,'2012-12-11 15:41:24','127.0.0.1',181,'auth','User 181 Logged-in');
INSERT INTO "auth_event" VALUES(12,'2012-12-11 22:55:08','127.0.0.1',181,'auth','User 181 Logged-in');

That means, according to this that the sequence value (the one related to auth_event.id) will not get updated.

And now comes my problem: the framework that I am using is not giving values to the serial field. That means that postgres is using the default value, and since it has not been updated, a collission occurs.

How can I update the sequence value related to auth_event.id after importing?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T11:50:36+00:00Added an answer on June 17, 2026 at 11:50 am
    select setval(pg_get_serial_sequence('auth_event' , 'id'), (select max(id) from auth_event) );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a three SQL tables: create table users ( id serial primary key,
I have created a table in postgresql 9 create table stillbirth(id serial primary key,
I have a table with properties defined like this : @Column(name=\SERIAL#\) When Hibernate inserts
I have defined a table type PL/SQL variable and added some data there. create
I have defined a rectangle drawable like this: <shape xmlns:android=http://schemas.android.com/apk/res/android android:shape=rectangle> <corners android:radius=4dip/> <solid
I have a tree structure in an sql table like so: CREATE TABLE containers
I have an entity defined with a sequence-generated primary key: @Id @GeneratedValue(strategy = GenerationType.SEQUENCE,
I have a standard webservice in ASP .Net 4.0 defined like this: [WebMethod] public
I have a database table in Scala Playframework defined as CREATE TABLE account (
Imagine we have a simple table create table a (id serial, data text); and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.