Oracle SQL Developer and PostgreSQL

Oracle SQL Developer 4.0.1.14 surely does support connections to PostgreSQL. download JDBC driver for Postgres (http://jdbc.postgresql.org/download.html) in SQL Developer go to Tools → Preferences, Database → Third Party JDBC Drivers and add the jar file (see http://www.oracle.com/technetwork/products/migration/jdbc-migration-1923524.html for step by step example) now just make a new Database Connection and instead of Oracle, select PostgreSQL … Read more

Insert if not exists, else return id in postgresql

Yes there is returning INSERT INTO tag (“key”, “value”) SELECT ‘key1’, ‘value1’ WHERE NOT EXISTS ( SELECT id, “key”, “value” FROM node_tag WHERE key = ‘key1’ AND value=”value1″ ) returning id, “key”, “value” To return the row if it already exists with s as ( select id, “key”, “value” from tag where key = ‘key1’ … Read more

pgadmin4 : postgresql application server could not be contacted.

I found the same issue when upgrading to pgAdmin 4 (v1.6). On Windows I found that clearing out the content inside C:\Users\%USERNAME%\AppData\Roaming\pgAdmin\sessions folder fixed the issue for me. I believe it was attempting to use the sessions from the prior version and was failing. I know the question was marked as answered, but downgrading may … Read more

How do you change the character encoding of a postgres database?

First off, Daniel’s answer is the correct, safe option. For the specific case of changing from SQL_ASCII to something else, you can cheat and simply poke the pg_database catalogue to reassign the database encoding. This assumes you’ve already stored any non-ASCII characters in the expected encoding (or that you simply haven’t used any non-ASCII characters). … Read more

ERROR: permission denied for relation tablename on Postgres while trying a SELECT as a readonly user

Here is the complete solution for PostgreSQL 9+, updated recently. CREATE USER readonly WITH ENCRYPTED PASSWORD ‘readonly’; GRANT USAGE ON SCHEMA public to readonly; ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT ON TABLES TO readonly; — repeat code below for each database: GRANT CONNECT ON DATABASE foo to readonly; \c foo ALTER DEFAULT PRIVILEGES … Read more