Sign up ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

Is there an efficient way to bulk import data into a PostgreSQL 9.4 database on RDS that makes extensive use of foreign key constraints? The standard method of using pg_restore fails because RDS does not appear to allow you to disable system triggers.

For example, using the command:

pg_restore --host foo.rds.amazonaws.com --port 5432 --username "bar" --role=rds_superuser --dbname "baz" --data-only --disable-triggers --no-owner --no-privileges --no-tablespaces --verbose --exit-on-error "baz.dump"

Results in error messages such as:

pg_restore: [archiver (db)] could not execute query: ERROR: permission denied: "RI_ConstraintTrigger_a_30548" is a system trigger Command was: ALTER TABLE xxxx DISABLE TRIGGER ALL;

share|improve this question
    
That is not bulk import data, that is database import with data only. :) BTW you can export data only or schema. –  Mladen Uzelac Apr 1 at 18:11

1 Answer 1

Here's a workaround that works for me:

Create the schema then dump the tables only, in order such that no FK constraint checks fail:

pg_dump --username=postgres --data-only --table=table_1 --table=table_2 --table=table_3 --table=... --format=custom foo > foo.dump

pg_restore will now work.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.