Use this tag to indicate that your question is about PostgreSQL version 13. Questions concerning database administration should go to https://dba.stackexchange.com/
Questions tagged [postgresql-13]
368 questions
-1
votes
2 answers
Create new related entity and enter its id into a link table
My foos each have a bar.
At least they're supposed to.
I now want to create and assign bars to all foos that don't.
bar is completely detached from foo, it only has an id serial that serves as its primary key
CREATE TABLE bar
(
id SERIAL PRIMARY…

User1291
- 7,664
- 8
- 51
- 108
-1
votes
1 answer
How to install pgcrypto extension on postgres13 on MacOS
I'm using postgres13 and running a somewhat old ruby on rails project, it has a few migrations and one of the first lines on those migration files is:
enable_extension "pgcrypto"
All the migrations with that fail.
After looking up online, most…

Gabriel Oliveira
- 72
- 8
-1
votes
1 answer
PgSQL function returning table and extra data computed in process
In PgSQL I make huge select, and then I want count it's size and apply some extra filters.
execute it twice sound dumm,
so I wrapped it in function
and then "cache" it and return union of filtered table and extra row at the end where in "id" column…

vanilla
- 43
- 1
- 5
-1
votes
1 answer
Efficiently aggregating with joined table and searching
I have the following table schemas on Postgres 13.4:
TBL1: id, name
TBL2: fk(TBL1), name
and I want to make a query such that given query will be searched both on TBL1's id and name, also TBL2's name column (any of these 3 match), while joining…

Alp
- 367
- 3
- 18
-1
votes
1 answer
SQL Join with multiple conditions
I need a query to fill the column netto from table test with values from lv from table co when two conditions (test.sp= co.sp) AND (test.ver= co.ver) are given
Table test:
sp
ver
netto
A
X
Null
B
Y
Null
C
Z
Null
Table…

Diego Santiago
- 3
- 2
-1
votes
2 answers
Optimal SQL to perform multiple aggregate functions with different group by fields
To simplify a complex query I am working on, I feel like solving this is key.
I have the following table
id
city
Item
1
chicago
1
2
chicago
2
3
chicago
1
4
cedar
2
5
cedar
1
6
cedar
2
7
detroit
1
I am trying to find the ratio…

codeyashu
- 55
- 2
- 7
-1
votes
1 answer
psql: /usr/pgsql-11/lib/libpq.so.5: no version information available
Using Fedora33 rn, tried to install Postgresql, was succesful initializing first db, haven't got any errors. Also installed pgadmin4 but couldn't create a server.
su -i -u postgres -c "psql"
tried this command and got: `
psql:…

Yigit Demiralp
- 33
- 4
-2
votes
1 answer
left join for multiple tables produce duplicate results
I have 3 tables
students (id, name)
student_class_relation (id, student_id, class_id)
class (id, class_name)
a student can have multiple classes associated with him/her
I need to take all student records with class details such as class name,…

Vishnu Roshan
- 25
- 2
- 12