2021年07月29日

PSQL

Ubuntu 20.04 PSQL

sudo -i -u postgres
psql




pg_dump database名 > backup_file名

psql dbname < infile



pg_restore -U "ユーザー名" -C -d "DB名" db.dump



タグ:PSQL Ubuntu 20.04
posted by a23 at 09:16| Comment(0) | PostgreSQL

2021年07月26日

SQL 月末 翌月

月初
SELECT DATE_TRUNC('month', now())
月末
SELECT DATE_TRUNC('month', now()) + '1 month' +'-1 Day'

PostgreSQLで月を加減するには?
select now()::date + interval '1month';

今日の1年後
select now()::date + interval '1year';
今日の1か月後
select now()::date + interval '1month';

select '2021/02/02'::date + interval '1month';
select '20210202'::date + interval '1month';
明日
select now()::date + interval '1day';








タグ:SQL 月末
posted by a23 at 15:29| Comment(0) | PostgreSQL

2021年07月20日

アプリケーションのデータベース接続が失われました:pgAdmin4 v5.5

01.png


アプリケーションのデータベース接続が失われました:
・ 接続がアイドル状態だったために、強制的に切断させられた
・ アプリケーションサーバか、データベースサーバが再起動された
・ ユーザのセッションがタイムアウトになった
新しいセッションを確立します。続行しますか?


postgresql pid 確認


SELECT * FROM pg_stat_activity;


SELECT pg_cancel_backend(847);
posted by a23 at 09:21| Comment(0) | PostgreSQL