2021年1月10日日曜日

Postgress(copyクエリ利用)

 以下、クエリになる。

---------------------------------------------------------------------

#!/bin/bash


DBNAME="dvdrental" # 接続するデータベース名

HOST="database-pg1.cksctvztkm5v.ap-northeast-1.rds.amazonaws.com"

tables=("actor")

day=$(date "+%m%d%Y%H%M")


# postgresqlでcopy出力

psql -U postgres -h $HOST -d $DBNAME -c "\COPY (select * from $tables where last_update::date = date 'now') TO '/tmp/$day"_""$tables".csv' WITH CSV DELIMITER ','"

----------------------------------------------------------------------



参照先:

https://docs.aws.amazon.com/ja_jp/AmazonRDS/latest/AuroraUserGuide/postgresql-s3-export.html


0 件のコメント:

コメントを投稿

k8s node version UP(1.34.1 > 1.34.2)

[ マスターノードでの準備と安全確保] 1)etcdctl クライアントのインストール: (未インストールの場合は必要) apt update apt install etcd-client 2)etcd バックアップの取得と退避 (最重要): ETCDCTL_API...