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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T05:45:47+00:00 2026-06-10T05:45:47+00:00

So as to restore a database from a dump, I want to temporarily disable

  • 0

So as to restore a database from a dump, I want to temporarily disable all the constraints in all the tables of my database, which content I have emptied ( postregsql 8.3).

Is there a safe way to modify a field in the pg_constraint table that easily allows to bypass the constraint ?

I don’t think so when I look at the documentation pg_constraint.

Is it possible to drop the pg_constraint table content, then refill it again ?

If not, how people do restore/copy databases with tables that are full of constraints and foreign keys ? (my destination database has the schema but all the columns are empty).

Edit: althought Erwin Brandstetter’s answer is the good answer (with wise warning) to my precise question… the solution to my general problem for avoiding foreign key errors during restore is to use the flag –disable-triggers when using pg_restore.

finally, my two lines commands are now:

pg_dump.exe  -h %ipAddress% -p 5432 -U postgres -F c -a -v -f %file% mydb
pg_restore.exe -h localhost -p 5432 -U postgres -d mydb -v %file%  --disable-triggers

and it works ok.

  • 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-10T05:45:48+00:00Added an answer on June 10, 2026 at 5:45 am

    You can …

    ALTER TABLE tbl DISABLE TRIGGER ALL;
    

    This disables all triggers of the table permanently. So don’t forget to later run:

    ALTER TABLE tbl ENABLE TRIGGER ALL;
    

    -> 8.3 manual

    You can …

    SET CONSTRAINTS ALL DEFERRED;
    

    This makes all deferrable constraints wait until the end of the transaction.
    -> 8.3 manual

    You should never tinker with tables in the system catalog manually unless you are a hacker and know exactly what you are doing. Mortal humans should use DDL commands exclusively to affect the system catalog.

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

Sidebar

Related Questions

I have a script in PostgreSQL which restores test database from dump every night.
I am trying to restore a MySQL database from a dump file in my
I want to restore a database from a file (Tasks → Restore → Database;
I'm trying to dump a database from another server (this works fine), then restore
I am trying to restore MySQL database data from a dump file, using C#
I have created a PostgreSQL database dump using psql . Now I want to
I have an mnesia database dump from an ejabberd server (DCD, DCL, and DAT
I tried running the following query to restore a database: restore database myDatabase from
When I copy a database from one server to another via backup and restore,
I need to restore a backup from a production database and then automatically reapply

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.