postgres=# CREATE DATABASE joba_finder;
CREATE DATABASE
postgres=# CREATE USER jf_user WITH PASSWORD 'qwerty';
CREATE ROLE
postgres=# \l joba_finder
Список баз данных
Имя | Владелец | Кодировка | LC_COLLATE | LC_CTYPE | Права доступа
-------------+----------+-----------+-------------+-------------+---------------
joba_finder | postgres | UTF8 | ru_RU.UTF-8 | ru_RU.UTF-8 |
(1 строка)
postgres=# GRANT ALL PRIVILEGES ON DATABASE joba_finder to jf_user;
GRANT
postgres=# \l joba_finder
Список баз данных
Имя | Владелец | Кодировка | LC_COLLATE | LC_CTYPE | Права доступа
-------------+----------+-----------+-------------+-------------+-----------------------
joba_finder | postgres | UTF8 | ru_RU.UTF-8 | ru_RU.UTF-8 | =Tc/postgres +
| | | | | postgres=CTc/postgres+
| | | | | jf_user=CTc/postgres
(1 строка)
postgres=# select version();
version
--------------------------------------------------------------------------------------------------------
PostgreSQL 11.2 (Debian 11.2-2) on x86_64-pc-linux-gnu, compiled by gcc (Debian 8.3.0-2) 8.3.0, 64-bit
(1 строка)
postgres=# select
postgres-# \l joba_finder
Список баз данных
Имя | Владелец | Кодировка | LC_COLLATE | LC_CTYPE | Права доступа
-------------+----------+-----------+-------------+-------------+-----------------------
joba_finder | postgres | UTF8 | ru_RU.UTF-8 | ru_RU.UTF-8 | =Tc/postgres +
| | | | | postgres=CTc/postgres+
| | | | | jf_user=CTc/postgres
(1 строка)
postgres-# 1;
?column?
----------
1
(1 строка)
The userland code is unaffected
Возможно ли не встравлять в таблицу записи, которые уже присутствуют в таблице?
SELECT Prop.*, coalesce("counters".countAllUnits, 0) AS "countAllUnits", coalesce("counters".countVacantUnits, 0) AS "countVacantUnits"
FROM "Property" AS Prop
INNER JOIN LATERAL
(
SELECT COUNT(*) AS countAllUnits,
count(*) filter(where "Unit".status = 'Vacant') as countVacantUnits
FROM "Unit"
WHERE Prop."id" = "Unit"."propertyId"
) AS "counters" ON true
WHERE Prop."userId" IN (
SELECT id FROM "User" WHERE "companyId" = 200001
)
ORDER BY Prop."userId" ASC LIMIT 10 OFFSET 0
Но первичный ключ является обязательным для каждой таблицы
Peer authentication failed for user "MyUser"
New versions of
currently installed packages that cannot be upgraded without
changing the install status of another package will be left at
their current version.