postgresqldatagrip

how to copy a table from one postgres db to another in datagrip?


I tried exporting the data to CSV and importing it to the new database, but it does not seem to respect the case sensitivity of column names. "createdAt" becomes "createdat" and does not change even when trying to modify the table. How do I do it correctly?


Solution

  • You can use the "dump" and "restore" feature of datagrip which uses pg_dump and pg_restore behind the scenes, this will respect the case-sensitivity of the column names.

    Here are the steps:

    1. Dump the database/table by right clicking on it and choose the Export with 'pg_dump' option, this will export the dump to selected destination. Make sure you add ".dump" as the destination file extension. Screenshot with description and explanation
    2. Restore the database/table by right clicking on your second database and choose the Restore... option, selected the file that you exported in step 1.

    Note: If the path to pg_dump or pg_restore is invalid, you can use the "which" command in your terminal and get the correct path from there.