Post

Delete database entries via bash alias

Delete database entries via bash alias — practical walkthrough with examples.

This bash alias provides a quick shortcut to delete a range of rows from a PostgreSQL table. It connects to the local database using psql and executes a DELETE statement via a here-string, removing entries with IDs between 1 and 10000.

1
alias delprn='psql "host=127.0.0.1 port=5432 sslmode=disable user=rednetwork password=password" <<< "delete from port_range_networks where id between 1 and 10000;"'
This post is licensed under CC BY 4.0 by the author.