Created
January 5, 2021 21:00
-
-
Save topaztee/ba55410fe8b8883c5314dae36be32f92 to your computer and use it in GitHub Desktop.
script to delete all test databases
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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