psql-将命令结果保存到文件 [英] psql - save results of command to a file

查看:249
本文介绍了psql-将命令结果保存到文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用psql的 \dt 列出数据库中的所有表,我需要保存结果。

I'm using psql's \dt to list all tables in a database and I need to save the results.

将psql命令的结果导出到文件的语法是什么?

What is the syntax to export the results of a psql command to a file?

推荐答案

在psql的帮助下( \?):

From psql's help (\?):


\o [文件]将所有查询结果发送到文件或| pipe

\o [FILE] send all query results to file or |pipe

命令序列如下所示:

[wist@scifres ~]$ psql db
Welcome to psql 8.3.6, the PostgreSQL interactive terminal

db=>\o out.txt
db=>\dt
db=>\q

这篇关于psql-将命令结果保存到文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆