@kyanny's blog

事実上すべての広告に見られる一貫したテーマとは、消費者の劣等性である - W・B・キイ「メディア・レイプ」

PostgreSQL: psql -c の結果でページャを無効にする

1. -P (--pset) オプションを使う

psql -P 'pager=off' -c '\dp'

2. 環境変数で PAGER=cat とする

PAGER=cat psql -c '\dp'

検証手順

1. コンテナを作る

docker run --rm -e 'POSTGRES_HOST_AUTH_METHOD=trust' --name aa -d postgres

2. テストデータを作る

for i in {1..100}; do docker exec aa psql -U postgres -c "create table tt$i (id int)"; done

3. psql -c する

ページャが有効な場合

docker exec -t aa psql -U postgres -c '\dp'
                            Access privileges
 Schema | Name  | Type  | Access privileges | Column privileges | Policies
--------+-------+-------+-------------------+-------------------+----------
 public | tt1   | table |                   |                   |
 public | tt10  | table |                   |                   |
 public | tt100 | table |                   |                   |
 public | tt11  | table |                   |                   |
 public | tt12  | table |                   |                   |
 public | tt13  | table |                   |                   |
 public | tt14  | table |                   |                   |
 public | tt15  | table |                   |                   |
 public | tt16  | table |                   |                   |
 public | tt17  | table |                   |                   |
 public | tt18  | table |                   |                   |
 public | tt19  | table |                   |                   |
 public | tt2   | table |                   |                   |
 public | tt20  | table |                   |                   |
 public | tt21  | table |                   |                   |
 public | tt22  | table |                   |                   |
 public | tt23  | table |                   |                   |
 public | tt24  | table |                   |                   |
 public | tt25  | table |                   |                   |
 public | tt26  | table |                   |                   |
 public | tt27  | table |                   |                   |
 public | tt28  | table |                   |                   |
 public | tt29  | table |                   |                   |
 public | tt3   | table |                   |                   |
 public | tt30  | table |                   |                   |
 public | tt31  | table |                   |                   |
 public | tt32  | table |                   |                   |
 public | tt33  | table |                   |                   |
 public | tt34  | table |                   |                   |
 public | tt35  | table |                   |                   |
 public | tt36  | table |                   |                   |
 public | tt37  | table |                   |                   |
 public | tt38  | table |                   |                   |
 public | tt39  | table |                   |                   |
 public | tt4   | table |                   |                   |
 public | tt40  | table |                   |                   |
 public | tt41  | table |                   |                   |
 public | tt42  | table |                   |                   |
 public | tt43  | table |                   |                   |
 public | tt44  | table |                   |                   |
 public | tt45  | table |                   |                   |
 public | tt46  | table |                   |                   |
 public | tt47  | table |                   |                   |
 public | tt48  | table |                   |                   |
 public | tt49  | table |                   |                   |
 public | tt5   | table |                   |                   |
 public | tt50  | table |                   |                   |
 public | tt51  | table |                   |                   |
--More--

ページャが無効な場合

docker exec -t aa psql -U postgres -P 'pager=off' -c '\dp'
                             Access privileges
 Schema | Name  | Type  | Access privileges | Column privileges | Policies
--------+-------+-------+-------------------+-------------------+----------
 public | tt1   | table |                   |                   |
 public | tt10  | table |                   |                   |
 public | tt100 | table |                   |                   |
 public | tt11  | table |                   |                   |
 public | tt12  | table |                   |                   |
 public | tt13  | table |                   |                   |
 public | tt14  | table |                   |                   |
 public | tt15  | table |                   |                   |
 public | tt16  | table |                   |                   |
 public | tt17  | table |                   |                   |
 public | tt18  | table |                   |                   |
 public | tt19  | table |                   |                   |
 public | tt2   | table |                   |                   |
 public | tt20  | table |                   |                   |
 public | tt21  | table |                   |                   |
 public | tt22  | table |                   |                   |
 public | tt23  | table |                   |                   |
 public | tt24  | table |                   |                   |
 public | tt25  | table |                   |                   |
 public | tt26  | table |                   |                   |
 public | tt27  | table |                   |                   |
 public | tt28  | table |                   |                   |
 public | tt29  | table |                   |                   |
 public | tt3   | table |                   |                   |
 public | tt30  | table |                   |                   |
 public | tt31  | table |                   |                   |
 public | tt32  | table |                   |                   |
 public | tt33  | table |                   |                   |
 public | tt34  | table |                   |                   |
 public | tt35  | table |                   |                   |
 public | tt36  | table |                   |                   |
 public | tt37  | table |                   |                   |
 public | tt38  | table |                   |                   |
 public | tt39  | table |                   |                   |
 public | tt4   | table |                   |                   |
 public | tt40  | table |                   |                   |
 public | tt41  | table |                   |                   |
 public | tt42  | table |                   |                   |
 public | tt43  | table |                   |                   |
 public | tt44  | table |                   |                   |
 public | tt45  | table |                   |                   |
 public | tt46  | table |                   |                   |
 public | tt47  | table |                   |                   |
 public | tt48  | table |                   |                   |
 public | tt49  | table |                   |                   |
 public | tt5   | table |                   |                   |
 public | tt50  | table |                   |                   |
 public | tt51  | table |                   |                   |
 public | tt52  | table |                   |                   |
 public | tt53  | table |                   |                   |
 public | tt54  | table |                   |                   |
 public | tt55  | table |                   |                   |
 public | tt56  | table |                   |                   |
 public | tt57  | table |                   |                   |
 public | tt58  | table |                   |                   |
 public | tt59  | table |                   |                   |
 public | tt6   | table |                   |                   |
 public | tt60  | table |                   |                   |
 public | tt61  | table |                   |                   |
 public | tt62  | table |                   |                   |
 public | tt63  | table |                   |                   |
 public | tt64  | table |                   |                   |
 public | tt65  | table |                   |                   |
 public | tt66  | table |                   |                   |
 public | tt67  | table |                   |                   |
 public | tt68  | table |                   |                   |
 public | tt69  | table |                   |                   |
 public | tt7   | table |                   |                   |
 public | tt70  | table |                   |                   |
 public | tt71  | table |                   |                   |
 public | tt72  | table |                   |                   |
 public | tt73  | table |                   |                   |
 public | tt74  | table |                   |                   |
 public | tt75  | table |                   |                   |
 public | tt76  | table |                   |                   |
 public | tt77  | table |                   |                   |
 public | tt78  | table |                   |                   |
 public | tt79  | table |                   |                   |
 public | tt8   | table |                   |                   |
 public | tt80  | table |                   |                   |
 public | tt81  | table |                   |                   |
 public | tt82  | table |                   |                   |
 public | tt83  | table |                   |                   |
 public | tt84  | table |                   |                   |
 public | tt85  | table |                   |                   |
 public | tt86  | table |                   |                   |
 public | tt87  | table |                   |                   |
 public | tt88  | table |                   |                   |
 public | tt89  | table |                   |                   |
 public | tt9   | table |                   |                   |
 public | tt90  | table |                   |                   |
 public | tt91  | table |                   |                   |
 public | tt92  | table |                   |                   |
 public | tt93  | table |                   |                   |
 public | tt94  | table |                   |                   |
 public | tt95  | table |                   |                   |
 public | tt96  | table |                   |                   |
 public | tt97  | table |                   |                   |
 public | tt98  | table |                   |                   |
 public | tt99  | table |                   |                   |
(100 rows)