Can I programatically(or whichever way works fine) create the backup of a database, with only the tables I want? I have around 100 tables in my database and I want only 10 tables backup(ofcourse all are interdependant). How can I achieve this? And by the way I have a postgresql database.
我可以以编程方式(或以任何方式工作正常)创建数据库的备份,只有我想要的表吗?我的数据库中有大约100个表,我只需要10个表备份(当然所有都是相互依赖的)。我怎样才能做到这一点?顺便说一下,我有一个postgresql数据库。
1 个解决方案
#1
13
Of course. pg_dump lets you pass list of tables with parameter -t
当然。 pg_dump允许您传递带参数-t的表列表
To clear some doubts. True, the -t
parameter accepts only one pattern. But it's a pattern very similar to regular expression, so if you want to dump tables A, B & C you can do:
要澄清一些疑惑。是的,-t参数只接受一种模式。但它的模式与正则表达式非常相似,因此如果要转储表A,B和C,您可以执行以下操作:
pg_dump -t '(A|B|C)'
#1
13
Of course. pg_dump lets you pass list of tables with parameter -t
当然。 pg_dump允许您传递带参数-t的表列表
To clear some doubts. True, the -t
parameter accepts only one pattern. But it's a pattern very similar to regular expression, so if you want to dump tables A, B & C you can do:
要澄清一些疑惑。是的,-t参数只接受一种模式。但它的模式与正则表达式非常相似,因此如果要转储表A,B和C,您可以执行以下操作:
pg_dump -t '(A|B|C)'