PostgreSQL 9.3, set database (or all) to read only mode Is any simple function/command for PostgreSQL 9.3 to set whole database to read only mode and then back to RW mode?
For example same as for MySQL:
FLUSH TABLES WITH READ LOCK;
LOCK TABLES customers READ;
UNLOCK TABLES;

or
FLUSH TABLES WITH READ LOCK;
SET GLOBAL read_only = 1;
SET GLOBAL read_only = 0;
UNLOCK TABLES;

Thanks.
default_transaction_read_only  might work for your case.
The command below will make new sessions start their transactions in read-only mode:
ALTER DATABASE name_of_database SET default_transaction_read_only to ON;

and to go back to normal:
ALTER DATABASE name_of_database SET default_transaction_read_only to OFF;

This takes effect for new sessions, not for sessions that are already connected.
The effect can also be obtained at the user level (which might be more convenient in some cases):
ALTER USER name_of_user SET default_transaction_read_only to ON;

While in read-only mode, a session can always issue SET default_transaction_read_only to OFF; to get out of this mode, or start any individual transaction with BEGIN read write;. But in general programs don't do that, so that default_transaction_read_only is sufficient to deny them the ability to write.