PostgreSQL: Show all the privileges for a concrete user

table permissions: select * from information_schema.role_table_grants where grantee=”YOUR_USER” ; ownership: select * from pg_tables where tableowner=”YOUR_USER” ; schema permissions: select r.usename as grantor, e.usename as grantee, nspname, privilege_type, is_grantable from pg_namespace join lateral ( SELECT * from aclexplode(nspacl) as x ) a on true join pg_user e on a.grantee = e.usesysid join pg_user r on … Read more

How to handle special characters in the password of a Postgresql URL connection string?

See Connection URIs in the doc. There are a few things that don’t seem quite right in your question: URIs are supported by postgres since version 9.2 only, so with a 9.1 client that’s not supposed to work at all. Or you’re using a client that implements connection URIs itself. Percent-sign encoding is supported. Per … Read more

How to create a new database with the hstore extension already installed?

Long story short: Install hstore in the template1 database: psql -d template1 -c ‘create extension hstore;’ Step-by-step explanation: As stated by the PostgreSQL documentation: CREATE EXTENSION loads a new extension into the current database. Installing an extension is database-specific. The following returns you the current database name: $ psql -c ‘select current_database()’ current_database —————— username … Read more

PostgreSQL date() with timezone

Basically what you want is: $ select starts_at AT TIME ZONE ‘UTC’ AT TIME ZONE ‘US/Pacific’ from schedules where id = 40 I got the solution from this article is below, which is straight GOLD!!! It explains this non-trivial issue very clearly, give it a read if you wish to understand pstgrsql TZ management better. … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)