UPDATE: Was able to exclude the data in the table durning the pg_dump command. Makes it even faster than trying to not load the data because you don't have to wait for that data to be dumped.
--exclude-table-data=event_logs
(PostgreSQL) 9.4.4
Anyone know how to exclude a table when doing a pg_restore
? I can find how to do it when doing a pg_dump
. However I am not the one doing the dump and can't exclude them.
There are 2 tables in the dump that are really big and take forever when I do a restore so I want to skip them.
I had the same problem. A long table list, and I want exclude the data from a few of the tables.
What I did was the following:
Run
pg_restore -l $pgdump_file > restore.pgdump.list
Open that restore.pgdump.list
file in an editor, and insert an ;
in front of the line saying
;2429; 0 27550 TABLE DATA public <table_to_explore> <database>
After saving the that file, it can now be used for importing, where all lines starting with ;
are ignored.
pg_restore -L restore.pgdump.list | psql
You could make an one-liner to add ;
in front of lines having a specific table name, if you completely want to ignore a specific table.
man pg_restore
is also telling about this in an example in the end of the documentation.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With