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 60527
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T18:10:33+00:00 2026-05-10T18:10:33+00:00

When there are one of more columns that reference another, I’m struggling for the

  • 0

When there are one of more columns that reference another, I’m struggling for the best way to update that column while maintaining referential integrity. For example, if I have a table of labels and descriptions and two entries:

Label | Description ------------------------------------ read  | This item has been read READ  | You read this thing already 

Now, I don’t want these duplicates. I want to add a constraint to the column that doesn’t allow values that are case-insensitively duplicates, as in the example. However, I have several rows of several other tables referencing ‘READ’, the one I want to drop.

I know Postgres knows which fields of other rows are referencing this, because I can’t delete it as long as they are there. So, how could I get any field referencing this to update to ‘read’? This is just an example, and I actually have a few places I want to do this. Another example is actually an int primary key for a few tables, where I want to add a new table as a sort of ‘base table’ that the existing ones extend and so they’ll all need to have unique IDs now, which means updating the ones they have.

I am open to recipes for functions I can add to do this, tools I can utilize, or anything else.

  • 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-10T18:10:34+00:00Added an answer on May 10, 2026 at 6:10 pm

    If you have many rows referencing READ, you could alter the foreign key to be on cascade update, update that table set Label = ‘read’ where Label = ‘READ’ and everything will get automagically fixed. After that you can alter the constraint again to be as it was before.

    To find all the tables referencing the column, you can use

    select TABLE_NAME,COLUMN_NAME,CONSTRAINT_NAME, REFERENCED_TABLE_NAME,REFERENCED_COLUMN_NAME from  INFORMATION_SCHEMA.KEY_COLUMN_USAGE where REFERENCED_TABLE_NAME = '<table>' AND REFERENCED_COLUMN_NAME = '<column>' 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

If there are more than one rows in my source that do not match
Is there any way to connect more then one PPC to ActiveSync in one
Is it possible that there are more than one certificate chain built during the
is there a way to configure trac to use more than one svn repo
Is there a way to set the fetchmode to eager for more than one
Of course I realize that there's no one right way to design a SQL
How can you disable the send -button if there is one or more input
Hey guys, one more quick question for any experts out there. I have a
There are more than one solution for finding the-number-of-digits in a given number. For
Are there any scenarios where more than one Box2D worlds are needed in one

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.