Joao Miguel Ferreira <jmf@estg.ipvc.pt> writes:
> I created 2 databases (user01db and user02db) owned by each of the
> users.
> Nevertheless, user02 can connect to the database of user01 (and
> vice-versa), create tables, select's, inserts, etc.
This is normal. If you don't want a particular user to be able to
connect to a particular database at all, you should alter pg_hba.conf
to prevent it. (As somebody suggested nearby, "sameuser" can be a
handy solution when your standard policy is that each user has a
database named after himself.)
As for what they can do after they've connected, the default behavior
is actually "not much" --- except that the "public" schema in each
database has public CREATE and USAGE permissions, so it's possible to
create tables within that schema. If you prefer you can lock down
the public schema more, or even remove it altogether. See the
discussion of privileges in the manual.
regards, tom lane