Questions tagged [postgresql-9.1]
for PostgreSQL questions specific to version 9.1.
1,805
questions
0
votes
0
answers
14
views
Get notification on react when there is change in the DB notification table using spring boot as back end
As a client, I need to get notified when there is a change in the DB table.
I'm maintaining a notification table
using spring boot
using react.js
can anyone suggest to me how to approach this ...
0
votes
2
answers
29
views
sql how to select row based on json format field value?
I have a table ,one of the table filed is json format:
my_table
id json_field
1 { "to_status": 7, "to_status_name": "In Progress", "role": "admin"...
0
votes
1
answer
64
views
Saving json array into postgresql data using spring boot java API
I have a Json Array in my request object and POJO object, I need to save that jsonarray field into jsonb column in my postgresql table.
"productId": "1",
"product":[
...
1
vote
0
answers
19
views
how to alter table to add two or more foreign keys
I tried using the code below to add two foreign keys to the table products but it wont add foreign keys if i run the two on one run, they work individualy but not if i code it the way below:
ALTER ...
2
votes
1
answer
32
views
How to query by time in postgresql
device_id
device_created_at
10e7983e-6a7b-443f-b0fe-d5e6485a502c
2022-08-10 20:55:16.695
i have a table where my date/time is of form: 2022-08-10 20:55:16.695 This is a timestampped object. I tried ...
0
votes
0
answers
46
views
How to drop a constraint starting with number in postgresql ? For ex : 123_5_pk_not_null
While dropping constraint named 123_5_pk_not_null, I am getting syntax error at the start of constraint name.
Query:
alter table table_name drop constraint 123_5_pk_not_null;
Error:
Syntax error at ...
0
votes
0
answers
117
views
not able to access PostgreSQL database & process-engine failing in IICS
I have by mistake deleted database files from folder(PostGreSql/Data/base) and now getting below error logs
getting below error in postgresql.log file
UTCLOG: database system is ready to accept ...
0
votes
0
answers
81
views
How to delete a DB when "-" is part of the database's name?
Basically I wrote the database name as "data-base", so now I can't remove it, because in postgre does not show it in the database list.
Like this question
And now I can't run some commands ...
0
votes
0
answers
58
views
Export then Import postgresql database
I'm going to upgrade postgreSQL from the version 9 to 11.
I've exported a database using this command C:\Program Files\PostgreSQL\11\bin\pg_dump.exe --file "C:\\Users\\bnechmi\\DOCUME~1\\db_kd&...
0
votes
1
answer
468
views
Upgrading from postgresql 9 to 11
I'm using a Linux server, I want to upgrade postgresql from the version 9 to 11. I have created a dump of my database. Then I have installed postgresql 11, now I want to import the dump to postgresql ...
0
votes
0
answers
9
views
Group supply using postgresql using Pivot dynamic function/crosstab function
I have a table :
Now I want to display the output like this:
I am using PostgreSQL and I am new to it how can create output like this.
0
votes
1
answer
121
views
TimescaleDB how to alter the retention policy's time interval
In timescale DB, it is not allowed to alter the retention time interval of a hyper table. Is there any work around or other ways to alter the time interval after a retention policy is set for a ...
1
vote
1
answer
27
views
How to move the only updated row to the hist_table postgres?
I Created the next Trigger to move the data from a main table to an historical table in case of an update or insert.
CREATE OR REPLACE FUNCTION process_employee_hist() RETURNS TRIGGER AS $...
2
votes
0
answers
561
views
Check if enum type exists and add value
I'm new to PostgreSQl. I'm trying to add new values to type if type exists:
ALTER type ProcessStatus ADD VALUE IF NOT EXISTS 'Processing';
Above query will add 'Processing' to type ProcessStatus, but ...
0
votes
0
answers
14
views
Importing a file from another machine to pgAdmin in Postgresql
I want to import data from another machine to pgAdmin using IP address in Postgresql. I then have to create an excel file in pgAdmin and import data into it with timestamp.
I am facing problems in ...
1
vote
1
answer
69
views
SQL merge row values in a column
TABLE 1
CODE
VALUE
AA
21
AA
32
AB
24
AC
22
AA
42
AC
20
AD
27
AD
28
AE
29
AF
31
AG
45
AE
51
AH
33
TABLE 2
CODE
KEY
AA
1
AB
2
AC
3
AD
4
AE
5
AF
6
AG
7
AH
8
Here i want to ...
0
votes
1
answer
100
views
how to restore postgreSQL 8.3 DB after unistall
I have unfortunately broken my old machine with postgres 8.3 on debian 6.0, I found a directory backup of postgresql database files, and i try to copy them on the new machine with a new version of ...
0
votes
1
answer
87
views
How to fetch data in a given interval in postgresql
SELECT time,CEIL(AVG(value)) from table
where col1 = 1
and col2='matchThis'
and col3>='2022-04-10T18:30:00.00Z'
and col3<='2022-04-25T12:58:23.00Z'
and mod(to_char(col3, 'MI')::...
1
vote
1
answer
2k
views
How to downgrade a postgres database from version 10 to 9.1?
I have a system that only supports version 9.1 of postgres and a client (company) has been managing their data with version 10. There are many tables and I need to know if there is a script to ...
0
votes
1
answer
129
views
KubeCTL with Postgres query doesn't work and throws "LINE 1: select * FROM "employees" where employeeData::text like someSampleHere;"
The field employeeData is of type json.
Consider the query:
select * FROM "employees" where employeeData::text like '%someSampleHere%'
When I'm running the query inside Postgres it works ...
0
votes
1
answer
110
views
How to get a JSON property value using PostgreSQL
I have a table named appsettings with columns value and key
key column = supported-api-client
in value column i have json like this
{
"DEV": [
{
"OS": &...
0
votes
1
answer
488
views
Strange bevaiour of session.add in sqhalchemy (duplicate key value violates unique constraint in session.add))
I encountered strange behaviour of SQLAlchemy
I tried to add a new object to the DB. This is done in the function add_tag()
class News(Base):
__tablename__ = "news"
id = Column(...
0
votes
2
answers
106
views
How to shorten json data in Postgres?
So, I have a table (Using postgres v9) that has an id(integer) and a json(text). This is the query that I use to fetch it:
select software_json from software_master where id=1;
And I get
{
"...
0
votes
0
answers
25
views
Use the script created by Vikas to send data to AWS IOT to kinesis to lambda to rds
– Use the script created by Vikas to send data to AWS IOT and forward the temperature and pressure data to Kinesis, create a kinesis triggered lambda function to store it in SensorData Table
0
votes
2
answers
301
views
django error with postgresql database on real host
this is my first python programe to run on server and i have error in database connection.
when i add this line to setting file
DATABASES = {
'default': {
'ENGINE': 'django.db.backends....
0
votes
1
answer
40
views
Notify using postgresql intervals
Say, like I have a table videoplan:
create table video_plan(
id integer,
startdate timestamp,
enddate timestamp)
So I'm having startdate: 01.02.2022, enddate: 28.02.2022
Here, I need to show a ...
0
votes
0
answers
76
views
Postgres:"Level of Rollback on Errors" parameter for odbc.ini in RHEL
Is there any parameter to set the value of the postgres odbc parameter "Level of Rollback on Errors" in Linux odbc.ini?
In Windows we have an option to check the option, however, I am not ...
0
votes
0
answers
34
views
how to return multiple result set in postgres, currently i am using refcursor for that . What would be the best solution in this scenario?
Hi I am using MySQL as my current dB but now we are switching it to postgres can anyone know how to write SPs in postgres and how can we return multiple data set in the postgres same as we return the ...
1
vote
1
answer
121
views
AWS Kinesis Analytics SQL to transform rows to a list
I have a Destination Stream that looks as follows for example :
Company_ID Product User_Tag Count
123 P1 T1 15
123 P1 T2 ...
0
votes
1
answer
556
views
While trying to drop 10000 tables in one short in postgres sql getting error out of shared memory increase max_locks_per_transaction
out of shared memory HINT: You might need to increase
max_locks_per_transaction.
We are passing input as comma separated tables table_names and trying to drop a huge
set of table
CREATE OR ...
0
votes
1
answer
291
views
postgres listen notification generates error - 53300: sorry, too many clients already
During listen notification from postgres trigger, we encounter Error 53300: sorry, too many clients already. Please suggest, if we can resolve it somehow. On closing connection object it stops sending ...
0
votes
0
answers
118
views
Postgres on conflict
CREATE FUNCTION get_or_create_id(scheduleid integer,member_id character varying, user_id integer,role_id integer, _appointment_date timestamp without time zone,active boolean) RETURNS INT AS
$$
WITH ...
1
vote
1
answer
1k
views
How to create index parallelly on two columns in postgres
I wanted to create two index on my table having 500 million rows, Since index creation will take some time to finish, I am thinking to run two indexes statement parallelly, But I don't know how, I ...
0
votes
0
answers
93
views
How to export and encode a "bytea" column as a Decimal representation in Postgres using PSQL?
I want to export a bytea column as a Decimal representation.
The binary exports works as follows:
\copy (SELECT right(wantedColumn::text, -1)::varbit FROM "myBigTable" LIMIT 1) TO '/tmp/...
0
votes
1
answer
212
views
insert datetime from csv to postgres error
I have a csv file:
with open(r'apps/patients/management/commands/events.csv') as csvfile:
spamreader = csv.DictReader(csvfile, delimiter=',' ,quotechar=' ')
for row in spamreader:
...
0
votes
0
answers
61
views
Best approach to get products in order from database ??? based on product properties
I have to show products on my ecommerce website when user search query to My Elasticsearch
And having following features
Order by user previous preference
order by hot products
0
votes
1
answer
119
views
A different filter for each group by member
For each subject I would like to filter their records after a specific date. However, the date I want to use as a filter is different for each subject. Is there a way to group by subjects then for ...
0
votes
2
answers
897
views
parse key:value pairs in SQL postgresql
I have a string that contains a semicolon separated list of key value pairs.
E.g ref:12345;code:ab etc.
I would like to split it into 'ab' as code,'241376' as ref,etc.
Any help really appreciated.
0
votes
1
answer
230
views
How to Write PostgreSQL Stored Procedure to find and kill idle query?
Need to write PostgreSQL Stored Procedure to find and kill Idle queries. Below are the query to find and kill PID:
To find list of PID:
SELECT pid FROM pg_stat_activity where datname='...
0
votes
1
answer
151
views
Ruby on Rails link_to method to change db value
Hello I am trying to change a string value from "no" to "yes" in my Rails Postgresql db based on if a user clicks a yes or no button using the link_to method in my view. I have ...
0
votes
1
answer
168
views
Restore databases from row files
I do not find the solution alone, hope you could help me.
I have one vm who hacked, rescue mode is activated. I can acces on this machine only via sftp protocol.
Is it possible to import bases from ...
0
votes
1
answer
35
views
Group and Sort based on JOIN and 2 different columns
Here is my current SQL code, which orders posts by created_at column:
select users.name as user_name, *
from posts
join users on users.id = posts.user_id
order by posts.created_at ...
0
votes
1
answer
480
views
Auto generate table id
I use this SQL query to generate test data into table:
INSERT into onboarding_tasks SELECT generate_series(1,10) AS id,
('ABC name ' || generate_series(1,10)) AS business_name;
As you can see the ...
0
votes
3
answers
423
views
Select and assign 0 for the rows which does not have any data
We have client requirement where if for a particular condition, there is no data available, then assign 0 while selecting the column from DB.
Below is the table structure. We need to pull last 6 ...
-1
votes
2
answers
723
views
How consider NULL as the MAX date instead of ignoring it in PostgreSQL?
I have a table to control user access to specific systems. The column "end_date" defines the limit date of those access. For example:
If "end_date" is NULL it means that users can ...
1
vote
1
answer
73
views
sql upsert statement- postgresql
Table
id | name | value
0 | apis | apple
I want to append ,orange to this value, value should look something like apple,orange
I am trying to execute this query however let's suppose the original ...
0
votes
0
answers
21
views
wanting to replace schema value of a sql script by providing schema value 'sdg_cdr' through shell script, but getting error
#!/bin/bash
schema_name_new=sdg_cdr
echo "Initial truncate of tables"
sed -i 's/"$schema_name"/"$schema_name_new"/g' delete.sql
psql -f delete.sql
echo "Tables ...
0
votes
1
answer
24
views
SQL/POSTGRESSQL trying to group by value 2 diffrent tables and then join them any ideas?
im trying to get a new table from two diffrent tables: retweet,likes. The new table need to include columns such as post_id, retweet_count and likes_count
I tried to use SQL queries like this.
SELECT ...
1
vote
1
answer
3k
views
ERROR: could not create replication slot "my_subscription": ERROR: logical decoding requires wal_level >= logical
I have followed exactly what have done here.
Everything is fine until the point where I connect subcription to publication by using the command below
CREATE SUBSCRIPTION my_subscription CONNECTION '...
0
votes
1
answer
231
views
Can't import backup from postgres to different server with the same version of postgres because of different monetary format
I'm moving my databases from Postgres 9.1.23 running on Debian 7.11 to a different server with Postgres 9.1.24 running on Debian 10 and I can't import one database that's using money data type because ...