Skip to content

Instantly share code, notes, and snippets.

@abelcallejo
Last active July 18, 2019 22:40
Show Gist options
  • Save abelcallejo/97ac42490ad6b8162252a3086d26d354 to your computer and use it in GitHub Desktop.
Save abelcallejo/97ac42490ad6b8162252a3086d26d354 to your computer and use it in GitHub Desktop.
Executing a PostgreSQL script using a local file

Executing a PostgreSQL script using a local file

postgresql

Execute the prepared script

psql --quiet -h hostname -U user_name -w -d postgres -f "/path/to/prepared_script.sql"
/** Deleting then recreating a database **/
\c postgres;
DROP DATABASE IF EXISTS database_name;
CREATE DATABASE database_name OWNER user_name;
\c database_name;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment