0

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?

5
  • 1
    That copy command is missing essential parts. It does neither copy FROM somewhere, nor TO - so what's it even supposed to do? Commented Mar 7, 2024 at 14:13
  • 1
    (See the snytax of PostgreSQL copy command in the docs: postgresql.org/docs/current/sql-copy.html ) Commented Mar 7, 2024 at 14:14
  • How was the dump generated? If you use, for instance, pg_dumpall, the first line of the generated command would be COPY employee (empid, name, position) FROM stdin;. Commented Mar 7, 2024 at 14:18
  • Are you getting this issue running the script through psql or pgAdmin4? I have seen issues with pgAdmin and COPY. I routinely run data only dumps that use COPY through psql with no issue. Add to your question text the complete error message as text(not as an image). Commented Mar 7, 2024 at 16:00
  • Then feeding C:\data-only-dump.sql to psql should not be an issue. Verify what @ÁlvaroGonzález mentioned. Commented Mar 8, 2024 at 16:43

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.