Can I grant privileges to a Postgres user on all schemas belonging to a database with one command or script? Let's say I have 20 different schemas on a Postgres database. I create a new user theUser and now I want to grant only the SELECT and INSERT privileges for this user on all schemas. Is there an easy way/script to do that?
Yes, using DO, cursors, execute, and the pg_namespace table:

DO $$DECLARE _schema record; _user name := '&lt;your_username&gt;'
BEGIN
  FOR _schema IN
    SELECT * FROM pg_namespace WHERE nspowner &gt; 10 OR nspname = 'public'
  LOOP
    EXECUTE 'GRANT SELECT, INSERT ON SCHEMA '||
            quote_ident(_schema.nspname)||' TO '||quote_ident(_user);
  END LOOP;
END;$$;