欢迎来到海上华帆的博客园子

记录一些学习过程中的心得体会,供自己和有缘人参考!

postgresql

常用命令

数据库层面

# 1. 只生成,不执行,先过目
sudo -u postgres psql -c "SELECT datname FROM pg_database WHERE datname LIKE 'group%';"

# 2. 确认无误后,批量生成并执行
sudo -u postgres psql -tAq -c "SELECT 'DROP DATABASE '||quote_ident(datname)||';' FROM pg_database WHERE datname LIKE 'group%';" \
| sudo -u postgres psql -d postgres
posted @ 2025-10-31 14:49  海上华帆  阅读(2)  评论(0)    收藏  举报