| 參數 | 說明 | 範例 |
|---|---|---|
| -U | 指定連線使用者 | pg_dump -U postgres mydb |
| -h | 指定主機位置 | pg_dump -h 127.0.0.1 mydb |
| -p | 指定連線埠號 | pg_dump -p 5433 mydb |
| -d | 指定資料庫名稱 | pg_dump -d mydb |
| -f | 輸出檔案 | pg_dump -f backup.sql mydb |
| -F | 輸出格式 (c=custom, d=directory, t=tar, p=plain) | pg_dump -F c mydb |
| -v | 顯示詳細執行過程 | pg_dump -v mydb |
| -Z | 壓縮等級 (0-9) | pg_dump -F c -Z 9 mydb |
| -j | 並行工作數 (僅限 directory 格式) | pg_dump -F d -j 4 -f dumpdir mydb |
| -n | 只匯出指定 schema | pg_dump -n public mydb |
| --exclude-schema | 排除指定 schema | pg_dump --exclude-schema=test mydb |
| -t | 只匯出指定資料表 | pg_dump -t users mydb |
| --exclude-table | 排除指定資料表 | pg_dump --exclude-table=logs mydb |
| -s / --schema-only | 只匯出 schema (不含資料) | pg_dump -s mydb |
| -a / --data-only | 只匯出資料 (不含 schema) | pg_dump -a mydb |
| -C | 在 dump 中加入 CREATE DATABASE | pg_dump -C mydb |
| -c / --clean | 在 dump 中加入 DROP 指令 | pg_dump -c mydb |
| --if-exists | DROP 指令加上 IF EXISTS | pg_dump --clean --if-exists mydb |
| --column-inserts | 使用明確欄位名稱的 INSERT 語法 | pg_dump --column-inserts mydb |
| --inserts | 使用 INSERT 而非 COPY | pg_dump --inserts mydb |
| --rows-per-insert | 每個 INSERT 包含的資料列數 | pg_dump --rows-per-insert=100 mydb |
| --no-owner | 不輸出物件擁有者資訊 | pg_dump --no-owner mydb |
| --no-privileges | 不輸出 GRANT/REVOKE | pg_dump --no-privileges mydb |
| --no-comments | 不輸出 COMMENT | pg_dump --no-comments mydb |
| --no-publications | 不輸出 publication | pg_dump --no-publications mydb |
| --no-subscriptions | 不輸出 subscription | pg_dump --no-subscriptions mydb |
| --binary-upgrade | 用於版本升級的特殊模式 | pg_dump --binary-upgrade mydb |
| --disable-triggers | 在匯入時停用觸發器 | pg_dump --disable-triggers mydb |
| --enable-row-security | 啟用 row security | pg_dump --enable-row-security mydb |
| --no-security-labels | 不輸出安全標籤 | pg_dump --no-security-labels mydb |
| --no-tablespaces | 不輸出 tablespace 指令 | pg_dump --no-tablespaces mydb |
| --no-unlogged-table-data | 不匯出 unlogged table 資料 | pg_dump --no-unlogged-table-data mydb |
| --quote-all-identifiers | 所有識別字加上引號 | pg_dump --quote-all-identifiers mydb |
| --section | 指定匯出區段 (pre-data, data, post-data) | pg_dump --section=data mydb |
| --snapshot | 指定一致性快照 ID | pg_dump --snapshot=snapid mydb |
| --lock-wait-timeout | 設定 lock 等待時間 | pg_dump --lock-wait-timeout=5000 mydb |
| --no-sync | 匯出後不執行 fsync | pg_dump --no-sync mydb |
文章標籤

留言功能已依作者設定調整顯示方式