使用pg_dump仅从数据库中的一个表中获取插入语句 [英] Using pg_dump to only get insert statements from one table within database
本文介绍了使用pg_dump仅从数据库中的一个表中获取插入语句的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在寻找一种使用 pg_dump $ c $从数据库中的特定表中将所有行作为
INSERT
语句获取的方法
I'm looking for a way to get all rows as INSERT
statements from one specific table within a database using pg_dump
in PostgreSQL.
例如,我有表A,表AI中的所有行都需要作为 INSERT
语句,
E.g., I have table A and all rows in table A I need as INSERT
statements, it should also dump those statements to a file.
这可能吗?
推荐答案
如果版本< 8.4.0
if version < 8.4.0
pg_dump -D -t <table> <database>
在<$ c之前添加 -a
$ c> -t 如果只希望插入,而没有CREATE TABLE等来首先设置表。
Add -a
before the -t
if you only want the INSERTs, without the CREATE TABLE etc to set up the table in the first place.
version > = 8.4.0
version >= 8.4.0
pg_dump --column-inserts --data-only --table=<table> <database>
这篇关于使用pg_dump仅从数据库中的一个表中获取插入语句的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文