如何在 postgresql 命令行上导出表

man*_*k13 3 postgresql

谁能告诉我怎么做?

(我知道这可能是一个愚蠢的问题,但我正在尝试学习如何使用 postgresql 的命令行)

~$ psql mybase
psql (9.1.3)
Type "help" for help.
Run Code Online (Sandbox Code Playgroud)

进而

mybase=# \dt



            List of relations
 Schema |        Name         | Type  |  Owner   
--------+---------------------+-------+----------
 public | xxxxxx              | table | postgres
 public | xxxxxxx             | table | postgres
 public | xxxxxxxxxxx         | table | postgres
 public | xxxxxxxx            | table | postgres
 public | xxxxxxxxx           | table | postgres
 public | xxxxxxxxx           | table | postgres
 public | xxxxxxxxxxxxxxxx    | table | postgres
 public | xxxxxxxxxxxx        | table | postgres
 public | xxxxxxxxxxxxxxxx    | table | postgres
 public | xxxxxxxxxx          | table | postgres
 public | xxxxxxxxx           | table | postgres
 public | xxxxxxxxxxxxxxxx    | table | postgres
 public | xxxxxxxx            | table | postgres
Run Code Online (Sandbox Code Playgroud)

只想要一张表然后进行恢复 =D 谢谢

a_h*_*ame 8

如果要创建包含数据的文本文件,请使用COPY命令(或在客户端上创建输出文件的psql命令\copy,而不是像COPY命令那样在服务器上创建)。

如果要创建 SQL 语句,请使用pg_dump

  • @maniat1k:对。如果您有多个同名表,您将额外提供模式`-n <myschema>` 以避免混淆。 (2认同)