postgres ERROR: insert or update on table "xxxxx" violates foreign key

Posted on 2009-04-16
Medium Priority
Last Modified: 2012-05-06
I found the following message within syslog.

< message >
postgres ERROR: insert or update on table "xxxxx" violates foreign key

I am not developer but manage server.

Would you please tell me the meaning and the solution.
Question by:chunzi
LVL 20

Accepted Solution

ChristoferDutz earned 750 total points
ID: 24156566
You are propably inserting a record into a table with foreign key constraints where one of the foreign key vlaues is not a valid key in the related table. Try adding the related record first and adding the data you want to insert after this.

Expert Comment

ID: 24170683
A foreign key is a data that must exist in a table 'B'  in order to insert or update data on a table 'A' because table 'A' references to this field in table 'B' and a constraint says "do not permint insert or update values in field 'X' of table 'A' while this value is not present in table 'B' "

Happens that you have any value in a specific field of table 'A' that is not present in table 'B', then the constraint reject this transacion a logs to syslog.

Are you batch importing or updating data?

Author Closing Comment

ID: 31570918

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Setting up Secure Ubuntu server on VMware 1.      Insert the Ubuntu Server distribution CD or attach the ISO of the CD which is in the “Datastore”. Note that it is important to install the x64 edition on servers, not the X86 editions. 2.      Power on th…
SSH (Secure Shell) - Tips and Tricks As you all know SSH(Secure Shell) is a network protocol, which we use to access/transfer files securely between two networked devices. SSH was actually designed as a replacement for insecure protocols that sen…
Steps to create a PostgreSQL RDS instance in the Amazon cloud. We will cover some of the default settings and show how to connect to the instance once it is up and running.
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial
Suggested Courses
Course of the Month17 days, left to enroll

862 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question