Skip to content

Instantly share code, notes, and snippets.

@topaztee
Created January 5, 2021 21:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save topaztee/ba55410fe8b8883c5314dae36be32f92 to your computer and use it in GitHub Desktop.
Save topaztee/ba55410fe8b8883c5314dae36be32f92 to your computer and use it in GitHub Desktop.
script to delete all test databases
# drop all test databases
sql="select datname from pg_database where datname like '%test_%'"
dbDelNames=`psql -U postgres -t -A -c "$sql"`
for dbName in ${dbDelNames[@]}
do
echo -e "\n\n[INFO] Drop $dbName.\n"
dropdb $dbName
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment