2013-11-26 71 views
13

我想從我的pg_dump命令中排除一個序列,該命令將輸出置於純文件中。有沒有辦法讓pg_dump排除特定的序列?

Command: /Library/PostgreSQL/8.4/bin/pg_dump --host localhost --port 5433 --username xxx --format plain --clean --inserts --verbose --file /Users/xxx/documents/output/SYSTEM_admin_20131126015325.sql --exclude-table public.table1 --exclude-table public.table2 mydatabase 

我知道有對此我上面使用表開關和作爲pg_dump documentation規定,您可以啓用/在和pg_restore結合tar格式禁用數據庫對象,但我不會使用pg_restore的。

非常感謝

格雷厄姆

回答

23

有兩種情況:

  1. 排除是由表你也擁有傾銷序列(典型案例:SERIAL列) 。
    請參閱:Dump a table without sequence table in postgres
    簡答:不,序列不能放在一邊。

  2. 該序列是不是由被傾銷的表所有的。然後可以使用--exclude-table開關排除它,就好像它是一個表一樣。

從pg_dump的文檔:

-T表 --exclude表=表

Do not dump any tables matching the table pattern. 

的圖案根據相同的規則解釋爲-t

還有約-t

-t表
--table =表

Dump only tables (or views or sequences or foreign tables) matching table 
+0

它是不是由表擁有的序列,所以排除表選項的偉大工程。 – Graham

相關問題