0

I have a GB PostgreSQL database dump. I need to import it into an Azure postgreSQL single server. I know the below command but I prefer the import done inside DB without command line in the hosting OS environment.

  • psql -U postgres -d mydatabase -f dumpfile.sql

Is there any db sql command to do the psql -f command job? For example, the MS sql server has several ways to do that (BULK INSERT, etc.) without powershell command line. Does pgSQL have similar functions?

Aussie
  • 83
  • 1
  • 10

1 Answers1

1

To import dump file there is only option to use psql command or \i 'path file' command through command line. To avoid command line, you can use pgadmin tool to work with Azure Postgres SQL database. Steps are as follows.

  1. Connect your Azure Postgres SQL to pgadmin.
  2. Right click on Your Database Name.
  3. Click on Restore.
  4. Select file dumpfile.sql.
  5. Click on Restore.

File will import successfully.

Pratik Lad
  • 4,343
  • 2
  • 3
  • 11
  • Is it possible to execute psql command in the Azure function Powershell? I thought pgSQL may have a statement like "restore database myDB from 'c:\db\mydb.bak'" in SQL server. – Aussie Aug 01 '22 at 12:44
  • There is [pg_restore](https://learn.microsoft.com/en-us/azure/postgresql/migrate/how-to-migrate-using-dump-and-restore#restore-the-data-into-the-target-database) command to restore the data into the target database from the dump file. – Pratik Lad Aug 01 '22 at 12:53
  • Is there any command for .sql dump file too? – Aussie Aug 02 '22 at 01:52