Do you need a hundred databases and users for training etc. in PostgreSQL?
Just a few lines of code:
[postgres8@oel7 data]$ cat create_databases.sh #!/bin/bash NUMOFDBS=100 for i in `seq ${NUMOFDBS}`; do psql -q -c "create user u${i} UNENCRYPTED password 'u${i}' NOCREATEDB NOCREATEROLE NOCREATEUSER" postgres createdb -O u${i} db${i}
done
Execute it and you are ready:
[postgres8@oel7 data]$ time ./create_databases.sh real 1m37.825s user 0m0.143s sys 0m0.109s
Have a look at the databases and its owners:
postgres=# \l+ Name | Owner | Encoding | Collate | Ctype | Access privileges | Size | Tablespace | Description -----------+-----------+----------+-------------+-------------+-------------------------+---------+------------+-------------------------------------------- db1 | u1 | UTF8 | en_US.UTF-8 | en_US.UTF-8 | | 6705 kB | pg_default | db10 | u10 | UTF8 | en_US.UTF-8 | en_US.UTF-8 | | 6705 kB | pg_default | db100 | u100 | UTF8 | en_US.UTF-8 | en_US.UTF-8 | | 6705 kB | pg_default | db11 | u11 | UTF8 | en_US.UTF-8 | en_US.UTF-8 | | 6705 kB | pg_default | db12 | u12 | UTF8 | en_US.UTF-8 | en_US.UTF-8 | | 6705 kB | pg_default | ...
Really, really easy. For dropping the databases:
[postgres8@oel7 data]$ cat drop_databases.sh #!/bin/bash NUMOFDBS=100 for i in `seq ${NUMOFDBS}`; do dropdb db${i} dropuser u${i} done