# 查出表中有重复的 id 的记录,并计算相同 id 的数量 SELECT user_id,COUNT(user_id) FROM games GROUPBY user_id HAVING (COUNT(user_id)>1) # 合集 合并 Helpers 表和 Games 表 的 user_id 字段 (ALL 是不去重) SELECT user_id FROM games UNIONALLSELECT assistance_user_id FROM helpers; # 统计上表中的字段重复的次数 SELECTcount,COUNT(count) FROM (SELECT user_id,COUNT(user_id) FROM (SELECT user_id FROM games UNIONALLSELECT assistance_user_id FROM helpers ) AS foo;
CREATE USER www WITH PASSWORD 'u867#eDgg6#2@elo098OIUh';
CREATE DATABASE my_app_prod OWNER www;
alter role www login createdb;
报错解决
1、macOS postgres 角色不存在
** (Postgrex.Error) FATAL 28000 (invalid_authorization_specification): role "postgres" does not exist
解决
psql -d postgres
CREATEDATABASE postgres WITH OWNER postgres;
CREATEUSER postgres SUPERUSER;
2、升级版本后,数据库无法启动
报错如下:
could not connect to server: No such file or directory Is the server running locally and accepting connections on Unix domain socket "/tmp/.s.PGSQL.5432"?
FATAL: database files are incompatible with server