Preview:
# here when tries to copy the table to csv file, was getting Erro Like
# /home/ubuntu/file.csv : permission denied 
# actually we are trying to copy or do/perform some action like excuting/read/write a new 
# file or exsting file, but understand one thing is from any user to any other user
# location directory if we want to perfom any thing we do not have permissions for that.
# we have to have a right access for that users directory.
# so here we are trying to copy/export  the table to  csv file from postgres to user        # Ubuntu's /home/ubuntu  Directroy for that we have to have permission of Rwx Permission on # ubuntu for that here we use - ''' sudo chown user:user <path/to/access> ''' to get access of
# ubuntu user.

\COPY person  TO /home/ubuntu/data.csv DELIMITER ',' CSV HEADER;
# Gets This error -- /home/ubuntu/data.csv: Permission denied
# now user chown as shown below to get permission of directory-path  to write/execute

sudo chown postgres:postgres /home/ubuntu/
downloadDownload PNG downloadDownload JPEG downloadDownload SVG

Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!

Click to optimize width for Twitter