pg_dump, --exclude-table-data

2020-02-01 Thread PG Doc comments form
The following documentation comment has been logged on the website:

Page: https://www.postgresql.org/docs/12/app-pgdump.html
Description:

I cannot find and understand what happens, if I will ommit the table data
for a table where primary keys are refenced by foreignkeys from other
tables. I think the integrity will break and such backup/dump is
unusable...? Or is there a way how to handle this during restore?

(What I want to do is anonymize the content. I don't want to give user data
(User table), but lot of foreignkeys reference them. Something like
exporting all the rows with only primary key and foreign keys (which meet my
needs if just int/bigint are used for keys) + random content in other
fields. I understand that this is difficult to achieve and the completely
omiitted data will be ok - if there is not integrity problem during
restore.)


Exsamples for COPY

2020-02-01 Thread PG Doc comments form
The following documentation comment has been logged on the website:

Page: https://www.postgresql.org/docs/12/sql-copy.html
Description:

It would be benefitial to add some more complex (real-life) exsamples to new
syntax

Eg:
Reading TAB-delimited UTF8 CSV file residing in local machine and Postrge is
installed into local machice (windows):
copy City (city_name, city_code) from 'C:\Temp\city_data.csv' (FORMAT csv,
HEADER true, DELIMITER E'\t', QUOTE '"', ENCODING 'UTF-8');

Writing semicolon-delimited CSV UTF-8 file to server temporary folder
forcing zip code numbers to quote:
copy (select id, street_name, zip_code from delivery_point) to
'/tmp/bi/place.csv' (format csv, header true, delimiter ';', quote '"',
FORCE_QUOTE (zip_code), encoding 'UTF-8');

Cheers