pg-dump

Postgres: Best way to move data from public schema of one DB to new schema of another DB

大兔子大兔子 提交于 2019-12-05 17:18:40
问题 I am new to Postgres and just discovered that I cannot access data of different databases in one SQL query. And also learned the concept of schema in Postgres. Now, I have two databases db1 and db2 Both have tables with same name in their public schema. Now, I want to create a new schema in db1 with name : new_schema And move data from db2.public to db1.new_schema What is the easiest way to do this ? 回答1: The simplest way to do that is to rename schemas. However you must be sure you are a

pg_dump without comments on objects?

二次信任 提交于 2019-12-05 12:42:00
Is there a way to perform a pg_dump and exclude the COMMENT ON for tables/views and columns ? I use extensively the COMMENT ON command to describe all objects, and often include newlines in them for clearer descriptions, e.g.: COMMENT ON TABLE mytable1 IS 'MAIN TABLE... NOTES: 1. ... 2. ... 3. ... '; However, since there are newlines in the dump as well, I cannot simply remove the comments with a grep -v 'COMMENT ON' command. Any other way to quickly remove these COMMENT ON from the dump ? I would actually do this with a two-stage dump and restore. Dump and restore the db as is or create a new

pg_dump serial datatype issues

怎甘沉沦 提交于 2019-12-05 11:48:13
Could someone explain to me why a PostgreSQL table created with the following scripts: CREATE TABLE users ( "id" serial NOT NULL, "name" character varying(150) NOT NULL, "surname" character varying (250) NOT NULL, "dept_id" integer NOT NULL, CONSTRAINT users_pkey PRIMARY KEY ("id") ) gets dumped by pg_dump in the following format: CREATE TABLE users( "id" integer NOT NULL, "name" character varying(150) NOT NULL, "surname" character varying (250) NOT NULL, "dept_id" integer NOT NULL ); ALTER TABLE users OWNER TO postgres; CREATE SEQUENCE "users_id_seq" START WITH 1 INCREMENT BY 1 NO MINVALUE NO

Doing pg_dump while still many active transaction

时光毁灭记忆、已成空白 提交于 2019-12-05 09:57:46
As subjects, what will happen to the backup file while there is still many active transaction in the database. Does it export realtime or just partially backups ? thanks in advance. pg_dump runs in a serializable transaction, so it sees a consistent snapshot of the database including system catalogs. However it is possible to get 'cache lookup failed' error if someone performs DDL changes while a dump is starting. The time window for this sort of thing isn't very large, but it can happen. See: http://archives.postgresql.org/pgsql-bugs/2010-02/msg00187.php pg_dump will give you a consistent

pg_dump on Database throwing error 'out of shared memory'

会有一股神秘感。 提交于 2019-12-05 06:09:16
Getting problem when taking backup on database contains around 50 schema with each schema having around 100 tables. pg_dump throwing below error suggesting that to increase max_locks_per_transaction . pg_dump: WARNING: out of shared memory pg_dump: SQL command failed pg_dump: Error message from server: ERROR: out of shared memory HINT: You might need to increase max_locks_per_transaction. pg_dump: The command was: SELECT tableoid, oid, prsname, prsnamespace, prsstart::oid, prstoken::oid, prsend::oid, prsheadline::oid, prslextype::oid FROM pg_ts_parser An updated of max_locks_per_transaction to

Comparing two postgres dump files

雨燕双飞 提交于 2019-12-05 01:31:57
How to compare postgres dump files? I have two dump files, dump1 and dump2 . And I want to compare these two dump files. Any help will be appreciated.. Thank you PostgreSql's dump files are like normal data files.. you can use any utility/tool to see the difference between them.. Most of the OS has build in utilities for this For example: linux: vimdiff dump1 dump2 ( http://alvinalexander.com/linux-unix/vimdiff-see-multiple-file-differences-visually ) On Windows: fc dump1 dump2 ( http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/fc.mspx?mfr=true ) You can use

will pg_restore overwrite the existing tables?

我是研究僧i 提交于 2019-12-05 00:07:56
Say I have two host servers s1 and s2. In both the servers i have a schema named n1, now i have made some changes to some of the tables present in schema n1 of s1. I want the same change to be done to schema n1 of server s2. what i am planning to do is to take a backup of the schema n1 of server s1 using pg_dump and restore in the server s2 using pg_restore. Now my question is ,since there is already the same schema n1 in the server s2 with the same set of tables. what the restore process will do? will it overwrite the existing tables or should i drop the existing schema of server s2 and

Can't copy table to another database with pg_dump

久未见 提交于 2019-12-04 16:57:17
I'm trying to copy a table from one database to another database (NOT schema). The code I used in terminal is as below: pg_dump -U postgres -t OldSchema.TableToCopy OldDatabase | psql -U postgres -d NewDatabase When I press Enter it requests postgres password I enter my pass and then It requests psql password. I enter it and press Enter. I receive lots of: invalid command \N ERROR: relation "TableToCopy" does not exist Both tables have UTF8 encoding. Am I doing something wrong? OS: windows XP Error output: psql:TblToCopy.sql:39236: invalid command \N psql:TblToCopy.sql:39237: invalid command

pg_dump: too many command line arguments

拜拜、爱过 提交于 2019-12-04 15:39:07
问题 what is wrong with this command: pg_dump -U postgres -W admin --disable-triggers -a -t employees -f D:\ddd.txt postgres This is giving error of too many command-line arguments 回答1: Looks like its the -W option. There is no value to go with that option. -W, --password force password prompt (should happen automatically) If you want to run the command without typing is a password, use a .pgpass file. http://www.postgresql.org/docs/9.1/static/libpq-pgpass.html 回答2: For posterity, note that pg

Can I selectively create a backup of Postgres database, with only certian tables?

*爱你&永不变心* 提交于 2019-12-04 14:59:06
Can I programatically(or whichever way works fine) create the backup of a database, with only the tables I want? I have around 100 tables in my database and I want only 10 tables backup(ofcourse all are interdependant). How can I achieve this? And by the way I have a postgresql database. Of course. pg_dump lets you pass list of tables with parameter -t To clear some doubts. True, the -t parameter accepts only one pattern. But it's a pattern very similar to regular expression, so if you want to dump tables A, B & C you can do: pg_dump -t '(A|B|C)' 来源: https://stackoverflow.com/questions/602730