When I do this command :
SELECT language, title FROM cms_title WHERE language != 'en' AND title != 'Blog';
I see the pages I want to copy from a DB on the development server to the production server.
So, my aim is to dump those specific pages and then insert them in the production DB.
My question is : Is it possible ? Is it the best practice / way of doing it ?
Thank you so much in advance for the time spent on my request.
First, make sure you are connected with both DataSources in Data Grip. Select Source Table and press F5 or (Right-click -> Select Copy Table to.) This will show you a list of all tables (you can also search using a table name in the popup window). Just select your target and press OK.
If you really have two distinct PostgreSQL databases, the common way of transferring data from one to another would be to export your tables (with pg_dump -t ) to a file, and import them into the other database (with psql ).
PostgreSQL SELECT statement syntax If you specify a list of columns, you need to place a comma ( , ) between two columns to separate them. If you want to select data from all the columns of the table, you can use an asterisk ( * ) shorthand instead of specifying all the column names.
I do it the following way:
1.create dump:
psql -h dbhost1 -d dbname -U dbuser -c "copy(SELECT language, title FROM cms_title WHERE language != 'en' AND title != 'Blog') to stdout" > dump.tsv`
2.import dump:
psql -h dbhost2 -d dbname -U dbuser -c 'copy cms_title from stdin' < dump.tsv
This will append imported data to the table.
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