{"id":49,"date":"2011-02-09T19:10:00","date_gmt":"2011-02-09T18:10:00","guid":{"rendered":"https:\/\/ilmarkerm.eu\/blog\/2011\/02\/script-to-import-a-table-to-another-schema-in-postgresql\/"},"modified":"2017-11-13T18:46:39","modified_gmt":"2017-11-13T17:46:39","slug":"script-to-import-a-table-to-another-schema-in-postgresql","status":"publish","type":"post","link":"https:\/\/ilmarkerm.eu\/blog\/2011\/02\/script-to-import-a-table-to-another-schema-in-postgresql\/","title":{"rendered":"Script to import a table to another schema in PostgreSQL"},"content":{"rendered":"<p>Tested with Centos 5 and PostgreSQL 8.4.<\/p>\n<p>Sadly PostgreSQL does not have remap_schema parameter in its data import tool pg_restore, so importing tables to another schema in destination database is a little bit tricky.<\/p>\n<p>Here is a Bash script I use to connect to the source database over SSH tunnel, export two tables (<i>srv.stat_export<\/i> and <i>disp.trip<\/i>) and then import them to the destination database under schema <i>etl<\/i>.<\/p>\n<p><script src=\"https:\/\/gist.github.com\/ilmarkerm\/af70763eb6a9d03c18360b71c02d03f0.js\"><\/script><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Tested with Centos 5 and PostgreSQL 8.4. Sadly PostgreSQL does not have remap_schema parameter in its data import tool pg_restore, so importing tables to another schema in destination database is a little bit tricky. Here is a Bash script I use to connect to the source database over SSH tunnel, export two tables (srv.stat_export and [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[19],"class_list":["post-49","post","type-post","status-publish","format-standard","hentry","category-blog-entry","tag-postgresql"],"_links":{"self":[{"href":"https:\/\/ilmarkerm.eu\/blog\/wp-json\/wp\/v2\/posts\/49","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ilmarkerm.eu\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ilmarkerm.eu\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ilmarkerm.eu\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ilmarkerm.eu\/blog\/wp-json\/wp\/v2\/comments?post=49"}],"version-history":[{"count":1,"href":"https:\/\/ilmarkerm.eu\/blog\/wp-json\/wp\/v2\/posts\/49\/revisions"}],"predecessor-version":[{"id":406,"href":"https:\/\/ilmarkerm.eu\/blog\/wp-json\/wp\/v2\/posts\/49\/revisions\/406"}],"wp:attachment":[{"href":"https:\/\/ilmarkerm.eu\/blog\/wp-json\/wp\/v2\/media?parent=49"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ilmarkerm.eu\/blog\/wp-json\/wp\/v2\/categories?post=49"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ilmarkerm.eu\/blog\/wp-json\/wp\/v2\/tags?post=49"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}