Blog Post

Microsoft Blog for PostgreSQL
1 MIN READ

Using COPY command in Azure Database for PostgreSQL

Bashar-MSFT's avatar
Bashar-MSFT
Former Employee
Aug 14, 2019

Postgres ‘COPY’ command can be used to transfer data between text files and database tables, in this article I will discuss how to avoid "ERROR: must be superuser to COPY to or from a file" while using Azure Database for PostgreSQL.

 

COPY command needs superuser and Azure database for PostgreSQL is a managed PaaS database server that doesn't give the server admin superuser privileges, interested to know why? read this. so if you execute COPY command from PgAdmin or psql utility you will run into the prementioned error as in the following screenshot:

 

 

Solution:

use psql command \copy (as the error message suggests) rather than copy,
\COPY my_table FROM 'C:/Users/bahusse/Desktop/file2.txt' DELIMITERS ',' CSV QUOTE '''';

 

Updated Aug 14, 2019
Version 2.0
No CommentsBe the first to comment