Enes
Enes

Reputation: 341

PostgreSQL pg_dump syntax error in Ubuntu

In ubuntu 16.04 when i want to run pg_dump it doesn't work i got this error syntax error. What is wrong ?

postgres=# pg_dump db_name > db_name1.sql
postgres-#
postgres-# ;
ERROR:  syntax error at or near "pg_dump"
LINE 1: pg_dump db_name > db_name1.sql
        ^
postgres=#

Upvotes: 1

Views: 3173

Answers (1)

Yasen
Yasen

Reputation: 4474

pg_dump is not an SQL command.

It is a stand-alone utility, so you cannot run it from SQL query. Follow the link for more information.

For your case: type \q<Enter> to quit from SQL-client and repeat your command again using shell prompt. Remember you should use your SQL-credentials. I.e.:

$ pg_dump -U <postgres_user_name> db_name > db_name1.sql`

Upvotes: 6

Related Questions