postgresql

Cross database query using dblink

Deadly 提交于 2021-02-10 17:44:38
问题 I'd like to use dblink in postgres to copy data from a local database to a remote one. This what I came up with: SELECT * FROM dblink('archive', 'INSERT INTO data SELECT * FROM local.data') It wont work and I think I understand why. I get the error relation "local.data" does not exist , If possible, Id like to run this inside a stored procedure on the local database, in other words I want to push the data to the 'archive' server, rather than pull it to the 'archive'. How can I tell postgres

How do you ensure values from a logging table match objects in other tables ?

試著忘記壹切 提交于 2021-02-10 16:18:51
问题 I have three tables. Two basic tables listing objects and a third table logging changes in database. Here is an example. create table individual (ind_id integer, age integer, name varchar); create table organisation (org_id integer, city varchar, name varchar); create TABLE log_table (log_id integer, object_id integer, table_name varchar, information json, log_date date); I want to ensure that any row in the log_table corresponds to an existing object in either the individual table or the

How do you ensure values from a logging table match objects in other tables ?

☆樱花仙子☆ 提交于 2021-02-10 16:17:39
问题 I have three tables. Two basic tables listing objects and a third table logging changes in database. Here is an example. create table individual (ind_id integer, age integer, name varchar); create table organisation (org_id integer, city varchar, name varchar); create TABLE log_table (log_id integer, object_id integer, table_name varchar, information json, log_date date); I want to ensure that any row in the log_table corresponds to an existing object in either the individual table or the

Postgresql trigger on user logon

对着背影说爱祢 提交于 2021-02-10 16:14:07
问题 I'm trying to figure out of a way of knowing as soon as a user logs into a Postgres database. Is there a way to define a trigger to fire when a user logs into the DB? Or is there a table or a system view that gets updated whenever anyone logs into the DB? 回答1: I don't think there's anything at the SQL level which can identify a logon event (i.e. no view you can query, and no trigger you can create). You can, however, write a server-side module (in C) which intercepts logon events via the

Postgresql trigger on user logon

自古美人都是妖i 提交于 2021-02-10 16:14:03
问题 I'm trying to figure out of a way of knowing as soon as a user logs into a Postgres database. Is there a way to define a trigger to fire when a user logs into the DB? Or is there a table or a system view that gets updated whenever anyone logs into the DB? 回答1: I don't think there's anything at the SQL level which can identify a logon event (i.e. no view you can query, and no trigger you can create). You can, however, write a server-side module (in C) which intercepts logon events via the

Postgresql trigger on user logon

故事扮演 提交于 2021-02-10 16:12:14
问题 I'm trying to figure out of a way of knowing as soon as a user logs into a Postgres database. Is there a way to define a trigger to fire when a user logs into the DB? Or is there a table or a system view that gets updated whenever anyone logs into the DB? 回答1: I don't think there's anything at the SQL level which can identify a logon event (i.e. no view you can query, and no trigger you can create). You can, however, write a server-side module (in C) which intercepts logon events via the

Filter rows based on values inside multiple JSONB columns

…衆ロ難τιáo~ 提交于 2021-02-10 15:49:36
问题 I am trying to search a table in a LIKE %str% fashion but on fields inside json values over multiple columns . I have a table which has three jsonb columns change , previous and specific_changes . As you might imagine the content is JSON but the structure of that json is not know ahead of time, therefor i can't use the -> or ->> in query like so: select * from change_log where change -> 'field' = '"something"' create table change_log ( id serial not null constraint pk_change_log primary key,

docker-compose: nodejs container not communicating with postgres container

蹲街弑〆低调 提交于 2021-02-10 15:39:06
问题 I did find a few people with a slightly different setup but with the same issue. So I hope this doesn't feel like a duplicated question. My setup is pretty simple and straight-forward. I have a container for my node app and a container for my Postgres database. When I run docker-compose up and I see the log both containers are up and running. The problem is my node app is not connecting to the database. I can connect to the database using Postbird and it works as it should. If I create a

Cannot connect with psql to dockerized postgres

佐手、 提交于 2021-02-10 15:13:32
问题 I'm having a problem connecting to a dockerized postgres This is the container: root@29de79c3cfa2:/# psql -U postgres -W Password for user postgres: psql (9.5.14) Type "help" for help. postgres=# From Mac terminal: psql --host localhos -p 5234 -U postgres -W Password for user postgres: psql: FATAL: role "postgres" does not exist $ docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 29de79c3cfa2 postgres:9.5 "docker-entrypoint.s…" 14 minutes ago Up 7 minutes 0.0.0.0:5234->5432/tcp

User defined PostgreSQL function in hibernate dialect throws exception

蓝咒 提交于 2021-02-10 15:10:33
问题 Is it possible to register a custom function written in database & written in extended hibernate Postgres Dialect as follows? Receiving function not exists exception on using this function in HQL. Postgres function: create or replace function ADD_DAYS(varDate timestamp without time zone, varNumber numeric) returns timestamp without time zone LANGUAGE sql AS $$ SELECT (varDate + varNumber * INTERVAL '1 day') $$; Java code: registerFunction("add_days", new SQLFunctionTemplate(StandardBasicTypes