3

I'm new to PostgreSQL and I'm working on pgAdmin 4. I have a dump file which I need to use to load the data from the dump file into the database. I have created a new database and I'm trying to load the data from the dump file into it. What I'm doing is, I'm opening the dump file on pgAdmin, it contains all the code which I just need to execute and the data will be loaded in the database. But when I'm executing the file, its showing me a syntax error at 1 line. The lines of that part of the code are given below.

COPY public.deals (id, startup_id, investor_group_id) FROM stdin;

1   51  2

2   33  7

3   3   5

4   17  9

5   27  10

6   41  12

7   45  3

8   19  13

9   2   11

10  11  10

\.

I'm getting the following error -

ERROR:  syntax error at or near "1"

LINE 89: 1 51 2

        ^

I don't know what to do. If somebody can help me that would be great.

4
  • is this 1 51 2 data directly in the same file your "copy" statement is in? Stdin will have to be redirected or read from another file. Commented Sep 5, 2018 at 19:20
  • Yes, everything is in the same file. First, its creating a table named public.deals and then its copying all that data into that public.deals from stdin. But its showing me that syntax error at that 1 52 2 line. Commented Sep 5, 2018 at 19:28
  • You can't do that in pgAdmin, not in that way anyway. Commented Sep 5, 2018 at 21:03
  • Is there a reason you're not using a data file that's separate? You CAN do an SQL dump where it all gets put into 1 file as SQL commands, however, you have to do the dump that way to begin with. If you need help doing that, let me know. Commented Sep 5, 2018 at 21:04

1 Answer 1

4

You cannot use pgAdmin to restore such a dump.

Use psql:

psql -U postgres -d mydb -f dumpfile
Sign up to request clarification or add additional context in comments.

3 Comments

Worked just fine. Thanks a lot. :)
@user401398 Hi, Can you please explain me how did you resolve the issue? I have been experiencing the same error. I'm using pgadmin4 and PostgreSql 16.
@satishdurga I guess he just did what I said in the answer (using the appropriate file and database names).

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.