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

  • SEARCH
  • Home
  • 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 167049
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T12:12:20+00:00 2026-05-11T12:12:20+00:00

I’ve run into a situation in our database where I need to shift the

  • 0

I’ve run into a situation in our database where I need to shift the timestamps of a number of records by a day, however I have a unique constraint that requires the an id field and a timestamp field to be unique.

Here is the table description.

Table 'public.eedata'    Column    |              Type              |                         Modifiers                           -------------+--------------------------------+------------------------------------------------------------  eedata_id   | bigint                         | not null default nextval('eedata_eedata_id_seq'::regclass)  user_id     | integer                        |   eeupload_id | bigint                         |   eetimestamp | timestamp(0) without time zone |  Indexes:     'pk_eedata' PRIMARY KEY, btree (eedata_id)     'eedata_user_id_key' UNIQUE, btree (user_id, eetimestamp)     'fki_eeuploadid' btree (eeupload_id) Foreign-key constraints:     'fk_eeupload_id' FOREIGN KEY (eeupload_id) REFERENCES eeupload(eeupload_id) ON UPDATE CASCADE ON DELETE CASCADE     'fk_user_id' FOREIGN KEY (user_id) REFERENCES users(user_id) ON UPDATE CASCADE ON DELETE CASCADE 

The problem in this case is caused by the eedata_user_id_key constraint. I can successfully subtract a day using,

update eedata set eetimestamp = eetimestamp - interval '1 day' where eeupload_id = xxx;

because the order that it applies the update in prevents any collisions, however when I try

update eedata set eetimestamp = eetimestamp + interval '1 day' where eeupload_id = xxx;

I get

ERROR:  duplicate key violates unique constraint 'eedata_user_id_key'

What I need to be able to do is either specify the order in which the update is applied (effectively an order by for an update statement) or the ability to suspend the constraint for a single update statement.

I’m using Postgres 8.1.11 if that matters.

  • 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. 2026-05-11T12:12:21+00:00Added an answer on May 11, 2026 at 12:12 pm

    Could you just remove the constraint for the duration of your update, and then add it back in when you’re done?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 196k
  • Answers 197k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer You can disable a key globally (for all applications) by… May 12, 2026 at 7:16 pm
  • Editorial Team
    Editorial Team added an answer Download them first, then cache them. If the cell needs… May 12, 2026 at 7:16 pm
  • Editorial Team
    Editorial Team added an answer Many distributions include boost in their official repositories, but do… May 12, 2026 at 7:16 pm

Related Questions

I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I have a French site that I want to parse, but am running into
I have text I am displaying in SIlverlight that is coming from a CMS
I am currently running into a problem where an element is coming back from

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.