ERROR: syntax error at or near "\" when running sql script via psql | pgAdmin | PostgresSQL

44 views Asked by At

I'm facing an issue while performing a pg_dump of an existing database into two SQL files.

  • One file is intended for a schema-only dump.
  • The other is for a data-only dump

The command for the schema-only dump executes successfully using the following command:

psql -u dbuser -d empDatabase -f C:\SchemaOnlyDump.sql

However, the data-only dump encounters an error, specifically,ERROR: syntax error at or near '\.'

psql -u dbuser -d empDatabase -f C:\DataOnlyDump.sql

The data-only dump file has the following content:

enter image description here

Looks like PostgreSQL is interpreting the '.' symbol as part of SQL syntax whereas it serves a special purpose within the context of COPY commands executed in 'psql'

How can I execute the data-only SQL to populate the data into the database?

0

There are 0 answers