可以echo
命令到psql输入:
for dbname in foo foofoo foobar barbar
do
echo """
CREATE DATABASE $dbname TEMPLATE mytemplate1
""" | psql
done
由于IDENT
插到pg_hba.conf
psql postgres -c "CREATE DATABASE mytemplate1 WITH ENCODING 'UTF8'
TEMPLATE template0"
试着:
psql mytemplate1 -f file
批处理示例:
#! /bin/sh
for file in /path/to/files/*; do
psql mytemplate1 -f "$file"
done