postgresql-9.6

Postgresql query for objects in nested JSONB field

不羁的心 提交于 2019-12-04 09:07:08
问题 I am using PostgreSQL 9.6, and I have a table named "ItemDbModel" with two columns looks like: No integer, Content jsonb Say I put many records like: "No": 2, {"obj":"x","Item": {"Name": "BigDog", "Model": "NamedHusky", "Spec":"red dog"}} "No": 4, {"obj":"x","Item": {"Name": "MidDog", "Model": "NamedPeppy", "Spec":"no hair"}} "No": 5, {"obj":"x","Item": {"Name": "BigCat", "Model": "TomCat", "Spec":"blue color"}} How can I query the table for: Records where "Content.Item.Name" contains "Dog"

PostgreSQL: Encrypt Column With pgcrypto

有些话、适合烂在心里 提交于 2019-12-04 04:16:29
I need to encrypt some columns in a PostgreSQL 9.6 database. The data being encrypted is inherently sensitive; however, the data are not passwords or other authentication credentials. This data will need to be decrypted for statistical analysis and consumption by users. After reading several questions and answers: Storing encrypted data in Postgres https://dba.stackexchange.com/questions/24370/how-to-use-aes-encryption-in-postgresql https://dba.stackexchange.com/questions/59942/secure-postgresql-database-encryption ... and considering these comments: ... it seems the biggest problem with using

query.on is not a function

两盒软妹~` 提交于 2019-12-03 10:37:38
I am trying to learn how to use javascript to connect to a postgresql database but when I try to log a query to the console using query.on(...), I get a type error that says "query.on is not a function". I have searched extensively on how to resolve this but can't seem to find any documentation on the .on function. I know that the connection is successful because when I query the db from terminal, the two new rows have been added. jsontest.js var pg = require('pg'); var conString = "postgres://[username]:[password]@localhost:5432/VONKTA1"; //username and password masked var client = new pg

postgis not available for all postgres users

走远了吗. 提交于 2019-12-02 04:32:27
When creating a new user on our Potgis enabled database I run into the strange issue that that new user cannot access the postgis extension while earlier created users can. With my user account I get the following output: mydb => SELECT postgis_version(); postgis_version --------------------------------------- 2.3 USE_GEOS=1 USE_PROJ=1 USE_STATS=1 (1 row) With the new user I get the following: mydb => SELECT postgis_version() mydb-> ; ERROR: function postgis_version() does not exist LINE 1: SELECT postgis_version() ^ HINT: No function matches the given name and argument types. You might need

Postgres find configuration files in linux

荒凉一梦 提交于 2019-12-01 09:37:35
I've spent lots of time to find Postgres configuration files like pg_hba.conf or postgresql.conf in different distributions of linux and also postgres versions itself! and I was very confused... Finally I found the global solution for it. First you should follow these steps: su - postgres psql For postgres configuration file : SHOW config_file; the output should be like this: postgres=# SHOW config_file; config_file ------------------------------------------ /etc/postgresql/9.6/main/postgresql.conf (1 row) and for hba_file use: SHOW hba_file; If you instance is not started and you can't select

postgresql timezone conversion 'EST' != '-05'

感情迁移 提交于 2019-12-01 09:08:07
问题 I am running PostgreSQL 9.6.6 on x86_64-pc-linux-gnu and my time zone is set to 'UTC'. Does anyone know why the results of the following SELECT statements are different? A) SELECT timezone('EST', '2017-12-21'); timezone --------------------- 2017-12-20 19:00:00 B) SELECT timezone('-05', '2017-12-21'); timezone --------------------- 2017-12-21 05:00:00 According to the pg_timezone_names table -05 should have the same offset as EST ... Any thoughts? Thanks. 回答1: https://www.postgresql.org/docs

Postgres find configuration files in linux

我怕爱的太早我们不能终老 提交于 2019-12-01 08:22:53
问题 I've spent lots of time to find Postgres configuration files like pg_hba.conf or postgresql.conf in different distributions of linux and also postgres versions itself! and I was very confused... 回答1: Finally I found the global solution for it. First you should follow these steps: su - postgres psql For postgres configuration file : SHOW config_file; the output should be like this: postgres=# SHOW config_file; config_file ------------------------------------------ /etc/postgresql/9.6/main

Error in creating SEQUENCEs when restoring the PostgreSQL database

孤者浪人 提交于 2019-12-01 03:28:12
UserX has following grants: CREATE ROLE "UserX" LOGIN PASSWORD 'pass'; CREATE DATABASE "DBX" WITH OWNER="UserX" ENCODING='UTF8' TABLESPACE=pg_default CONNECTION LIMIT=-1; GRANT CONNECT ON DATABASE "DBX" TO "UserX"; GRANT USAGE ON SCHEMA public TO "UserX"; GRANT SELECT,INSERT,UPDATE,DELETE ON ALL TABLES IN SCHEMA public TO "UserX"; ALTER DEFAULT PRIVILEGES GRANT ALL ON TABLES TO "UserX"; ALTER DEFAULT PRIVILEGES GRANT ALL ON SEQUENCES TO "UserX"; I get following errors when trying to restore its dump to other database: pg_restore: creating SEQUENCE "public.tblX_Id_seq" pg_restore: [archiver (db

Error in creating SEQUENCEs when restoring the PostgreSQL database

感情迁移 提交于 2019-11-30 23:55:03
问题 UserX has following grants: CREATE ROLE "UserX" LOGIN PASSWORD 'pass'; CREATE DATABASE "DBX" WITH OWNER="UserX" ENCODING='UTF8' TABLESPACE=pg_default CONNECTION LIMIT=-1; GRANT CONNECT ON DATABASE "DBX" TO "UserX"; GRANT USAGE ON SCHEMA public TO "UserX"; GRANT SELECT,INSERT,UPDATE,DELETE ON ALL TABLES IN SCHEMA public TO "UserX"; ALTER DEFAULT PRIVILEGES GRANT ALL ON TABLES TO "UserX"; ALTER DEFAULT PRIVILEGES GRANT ALL ON SEQUENCES TO "UserX"; I get following errors when trying to restore

How to install Postgis to a Keg installation of Postgres@9.6 using Homebrew?

早过忘川 提交于 2019-11-29 03:06:24
问题 I have installed Postgresql@9.6 and Postgis via Homebrew. However, installing Postgis via Homebrew installs the latest version of Postgresql at 10 as dependency and pinning Postgresql at 9.6.5 blocks the install of Postgis via Homebrew. Performing 'CREATE EXTENSION postgis;' returns: ERROR: could not open extension control file "/usr/local/Cellar/postgresql@9.6/9.6.5/share/postgresql@9.6/extension/postgis.control": No such file or directory I've also tried uninstalling the Postgresql (at 10)