PostgreSQL on RDS: How to bulk import data with FK constraints? 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;
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 &gt; foo.dump

pg_restore will now work.