Copy Tables Between Two Databases

Overview

I would like to copy two tables between to PostgreSQL databases (in the same cluster). I will present a procedure based on what I found at:

http://www.jgronline.com/?p=8

Display Source Table Info

Let’s warm up by displaying the source table info in a manner we’ll re-use here shortly:

psql tpro_online_dev -c "select * from online.displayable_items"

Copy Table

Let’s copy the table displayable_items from one db to another:

psql tpro_online_dev -c "copy online.displayable_items to stdout"

My tags:
 
Popular tags:
 
Powered by MojoMojo