Answers:
首先,如果您尚未安装contrib
:
sudo apt-get install postgresql-contrib
要遍历几个数据库:
sudo su postgres;
for db in $(psql -c "SELECT datname FROM pg_database WHERE datistemplate = false;" | sed '1,2d' | head -n -2 | grep -v '^ postgres$'); do
echo "Adding adminpack to ${db}"
psql -c "CREATE EXTENSION adminpack;" ${db};
done
作为单线:
sudo su postgres;
for db in $(psql -c "SELECT datname FROM pg_database WHERE datistemplate = false;" | sed '1,2d' | head -n -2 | grep -v '^ postgres$'); do psql -c "CREATE EXTENSION adminpack;" ${db}; done