Skip to content
Advertisement

phpPgAdmin: how to duplicate an exact table from one database to another

enter image description here

Just as the title says, I want to duplicate one table from a completely separate database in phpPgAdmin to another one. I have tried two ways but both did not work for me:

  1. Tried “Create table like” (database >> table >> create table like)
    • this seems to can only duplicate a table within the database
  2. Tried export and import
    • I tried to export the table I want, then heading over to the other database and try to import in an empty table. but the error i am getting is either “Import error: File could not be uploaded to the server phppgadmin” or “Import error: Failed to automatically determine the file format.”

Advertisement

Answer

you can use pg_dump , which extract PostgreSQL database/table and the pipe it directly to another server/database

pg_dump -t table_name source_db | psql target_db

for more info read pg_dump documentation.

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement