Forrest logo
back to the psql tool

postgresql:import:sql

Import SQL dump into a PostgreSQL database
$ psql ${database_name} < ${database_dump}
try on your machine

This command is used to execute a PostgreSQL command-line utility called "psql" to import a database dump file into a PostgreSQL database. Here is the breakdown of the command:

  • "psql": It is the PostgreSQL command-line utility that allows you to interact with the PostgreSQL database using the command line.

  • "${database_name}": It is a placeholder for the name of the target database where you want to import the database dump. You need to replace "${database_name}" with the actual name of the database you want to import the dump into.

  • "<": This symbol is used to redirect the input of the command. In this case, it means that the input for the "psql" command will come from another file.

  • "${database_dump}": It is a placeholder for the name and location of the database dump file that contains the SQL statements necessary to recreate the database structure and data. You need to replace "${database_dump}" with the actual name and location of your database dump file.

By combining these parts, the command instructs the "psql" utility to connect to the specified database and import the SQL statements from the provided database dump file, effectively recreating the database structure and data.

This explanation was created by an AI. In most cases those are correct. But please always be careful and never run a command you are not sure if it is safe.
back to the psql tool