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

Posted on 2009-04-16
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

    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.
    LVL 6

    Expert Comment

    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


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Why You Should Analyze Threat Actor TTPs

    After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

    Network Interface Card (NIC) bonding, also known as link aggregation, NIC teaming and trunking, is an important concept to understand and implement in any environment where high availability is of concern. Using this feature, a server administrator …
    Join Greg Farro and Ethan Banks from Packet Pushers ( and Greg Ross from Paessler ( for a discussion about smart network …
    Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
    Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…

    737 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

    Need Help in Real-Time?

    Connect with top rated Experts

    22 Experts available now in Live!

    Get 1:1 Help Now