Postgresql – Error importing back a postgres db after dumping

postgresql

I dumped my postgres db using pgAdmin in plain format because I wanted to search for some text on it. After doing the search, I decided to import the db back from the sql query window but I get this error

ERROR: syntax error at or near "330"
LINE 48882: 330 643 644 1 2012-01-11 16:04:20.468 2012-01-17 22:33:23.99...

This is the part that gives the error. I know I didn't modify anything here. It is what it dumped for me

COPY account_account (id, parent_left, parent_right, create_uid, create_date, write_date, write_uid, code, reconcile, currency_id, user_type, active, name, level, company_id, shortcut, note, parent_id, currency_mode, type) FROM stdin;
330 643 644 1   2012-01-11 16:04:20.468 2012-01-17 22:33:23.993 1   40300010    f   \N  8   t   Rent Income 5   1   \N  \N  329 current other
55  89  94  1   2012-01-05 23:50:08.524 2012-01-10 12:32:51.934 1   12000000    f   \N  18  t   Long Term Investments   3   1   \N  \N  24  current view

Here is the code that creates the table

CREATE TABLE account_account (
    id integer NOT NULL,
    parent_left integer,
    parent_right integer,
    create_uid integer,
    create_date timestamp without time zone,
    write_date timestamp without time zone,
    write_uid integer,
    code character varying(64) NOT NULL,
    reconcile boolean,
    currency_id integer,
    user_type integer NOT NULL,
    active boolean,
    name character varying(128) NOT NULL,
    level integer,
    company_id integer NOT NULL,
    shortcut character varying(12),
    note text,
    parent_id integer,
    currency_mode character varying(16) NOT NULL,
    type character varying(16) NOT NULL
);

I am so confused here. Please what could be the problem

Best Answer

The problem is that you cannot COPY FROM stdin with pgAdmin (no stdin available in the query window), but you can easily restore the dump with psql

psql <database> -h <host> -p <port> -f <dump-file>

Hope that helps.