Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
552 views
in Technique[技术] by (71.8m points)

postgresql - Postgressql: copy data from prod database to dev database for some tables only

I've been tasked to copy some tables from the prod environment to the dev environment. These tables obviously exclude any user/account related tables. The databases are in separate RDS instances. The databases are datawarehouse_production and datawarehouse_development.

The issue I'm current facing is that I'm using DBeaver and am able to create DB dumps so for example, I create a dump for table 'responses' now when I try to use that dump and restore it to the dev environment, I get an error that says:

pg_restore: error: could not execute query: ERROR:  must be owner of relation responses

Command was: ALTER TABLE public.responses OWNER TO datawarehouse_production;

I can't even open the bloody dump files because they're binary. Here's what the dump file looks like: enter image description here

I wish to get rid of those queries that do for example: Drop database datawarehouse_production as the database I want to copy data to is datawarehouse_development.

I'm aware DBeaver has a transfer data feature but that is incredibly slow (50 mins for 20,000 rows). I've used it for smaller tables however the data I need to copy are 11 million rows.

I've also tried exporting the data to CSV from prod tables then loading them into dev tables however it's just as slow.

EDIT: After adding the --data-only flag: enter image description here

EDIT 2: Finally managed to make things work. Here's the backup settings window: enter image description here

And when restoring the dump, had to add --data-only flag in the extra command flags field!

question from:https://stackoverflow.com/questions/65661835/postgressql-copy-data-from-prod-database-to-dev-database-for-some-tables-only

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

Please log in or register to reply this article.

OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...