将执行的结果保存到文件

最近更新时间: 2024-06-12 15:06:00

postgres=# \o /data/tbase/log.txt 
postgres=# select * from tbase where id=1;
postgres=# \! cat /data/tbase/log.txt 
 id | mc 
----+----
  1 | 1
  1 | 2
  1 | 2
(3 rows)

postgres=# \o
postgres=# select * from tbase where id=1;
 id | mc 
----+----
  1 | 1
  1 | 2
  1 | 2
(3 rows)