Bye Bye Moore

PoCソルジャーな零細事業主が作業メモを残すブログ

psqlの-cオプションなら、ワンライナー程度の内容なら確認できる

psqlの-cオプションなら、ワンライナー程度の内容なら確認することができます。

$ psql mydb -c "select city from weather"
     city      
---------------
 San Francisco
(1 row)

例の魔界めいたバックスラッシュ記法も。とりあえず確認するときには有効ですね

$ psql mydb -c "\d"
           List of relations
 Schema |  Name   | Type  |   Owner    
--------+---------+-------+------------
 public | cities  | table | shuzo_kino
 public | weather | table | shuzo_kino
(2 rows)

$ psql mydb -c "\d weather"
           Table "public.weather"
 Column  |         Type          | Modifiers 
---------+-----------------------+-----------
 city    | character varying(80) | 
 temp_lo | integer               | 
 temp_hi | integer               | 
 prcp    | real                  | 
 date    | date                  |