Search Postgresql Archives

pg_dump and pg_restore problem

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi all,
I had a big problem that made me crazy... I want to simple backup some
tables from a my db and restore them to another.

My db:
table_two(
    id serial PRIMARY KEY,
    ...
)
table_one (
    id serial PRIMARY KEY,
    real_name text NOT NULL,
    username text NOT NULL,
    id_table_two integer REFERENCES table_two(id),
    ...
)
table_three (
    id serial PRIMARY KEY,
    id_user integer REFERENCES table_one (id) NOT NULL,
)...

For do this, I use pg_dump with two pass:
pg_dump --format=c --schema-only my_db > file_schema
pg_dump --format=c -a -t table_one -t table_two -t table_three > file_data

when I, into another host (same 8.3.7 version), execute the pg_restore I
receive a striking reply:

(drop db && create db && pg_restore -d my_db file_schema &&
pg_restore -d my_db file_data)

g_restore: [archiver (db)] Error while PROCESSING TOC:
pg_restore: [archiver (db)] Error from TOC entry 1877; 0 16395 TABLE
DATA table_thee my_db
pg_restore: [archiver (db)] COPY failed: ERROR:  insert or update on
table "table_three" violates foreign key constraint
"table_thee_id_user_fkey"
DETAIL:  Key (id_user)=(644) is not present in table "table_one".
WARNING: errors ignored on restore: 1

On the 2^th host whit a "select id from table_one where id=644" I see
the data
there! And on table_three (of course?) there is no data...

Moving the pg_dump to the standard sql format, inside the sql file I see
that the table_three id_user=644 are the first of the exported records

The unique solution that I found it's that to export with pg_dump all my
tables except the table_three and, after, exporting only that and on the
other host and import that alone...

It's this a normal behavior, a "missing feature", or...?

Thanks,
Michele


--
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux