Extract a sub set of the tables from a schema in a postgres database.  

The purpose for doing this most likely would be; you added several tables to an existing schema, then you developed some software system to use those new tables.  Once you get the system working and bug free in dev, you want to package up just the changes to ship as a script for your production release.

/usr/local/pgsql/bin/pg_dump -t truncate_tasks \
                             -t truncate_list \ 
                             -t summary_hour_memory \
                             -t summary_minute_memory \ 
                             -t sumry_events_task \ 
                             -t sumry_evnts_ident_ap_dy  \
                             -t sumry_evnts_ident_rel_dy \ 
                             -t sumry_evnts_mh_ap_pid_dy  \
                             -t sumry_evnts_mh_ap_pid_hr  \
                             -t sumry_evnts_mh_ap_pid_min  \
-s -U postgres test-db

 

What do each of the commands mean?

  • each of the "-t TABLE_NAME" options means include table TABLE_NAME in the export.
  • -s means schmea only don't export any of the underlying data.
  • -U indicates which user to use  'postgres' is the postgres super user.
  • the last argument is the database (this commands assumes you are doing the export from the same box as the database you are on, and that the database is running on the default port of 5432)

 




Please type the letters and numbers shown in the image.
 Captcha CodeClick the image to see another captcha.