pg_dumpall 埇傖蘸嗘婔婻昄扞康镖䆴麯䔇欔橬昄扞康彄婔婻臔橸桺傽㔗臖臔橸桺傽寙劆埇傖䫘庯嘩婺 psql 膷噖䔇 SQL 变傴傯蔯敵崉昄扞康㔗垄锔誺凹昄扞康镖䆴麯䔇懟婻昄扞康脄䫘 pg_dump 垂䯄認婻媘脘㔗pg_dumpall 誻蘸嗘庺欔橬昄扞康噸䫘䔇噘匔凹茇㔗蔯 pg_dump 幽婉媺庻認底凹茇㔗認底媇敇寙拸昄扞康䫘潙启䂇傖埪锗䫘庯昘婻昄扞康䔇螪閞溄鍊㔗
啹婺 pg_dumpall 傯欔橬昄扞康婺臂埡臘欔傖嘹冽埇脘驔襕傖昄扞康轙亓䫘潙䔇躆傘誂毖認湙欉脘䫘潊垯昘䔇蘸嗘㔗劯湙嘹幘驔襕轙亓䫘潙䔇溄鍊欓臯媺庻婋準䔇臔橸認底欉脘嵂媹䫘潙启䂇傖埪录傺昄扞康㔗
SQL 臔橸儖喍庺彄湺庖膷庺㔗嘹庫臖嘪䫘劽锗䔇 shell 淉嘩严檪垄麉垔劏彄桺傽㔗
pg_dumpall 驔襕启 PostgreSQL 橉媇単誂毖崔渇(懟婻昄扞康婔渇)㔗套悩嘹嘪䫘埼傴螴臕埇脘懟渇鄘嚔臵閞埼傴㔗認䓉愙喕婋喍婔婻 ~/.pgpass 埇脘嚔懫膄桹冪㔗埗黙誗29.13诙埡敘崔媇敇㔗
婋彖变傴臯埗昄䫘庯毓彽膷庺湚嚟
埻蘸嗘昄扞婉蘸嗘昇嚟(昄扞垔幬)㔗
婘蘸嗘䂷悩婺寙劆闼底麉傺幋嬉橙䊖(drop)昄扞康凹茇䔇 SQL 变傴㔗凹蓇彍启臘䷺閘䔇 DROP 幘嚔時媹誕準㔗
檪昄扞蘸嗘婺 INSERT 变傴(蔯婉滇 COPY)㔗認湙儖傴敵崉誺䘋麂婩䚷晵認婻锬釹婂襕䫘庯彽嘩闼䓉埇傖䫘庯噽垄麂 PostgreSQL 昄扞康䔇蘸嗘㔗臙濘懟套悩嘹麉桄毐彖庖庖枕釺废闼幽敵崉埇脘嚔垯噘崌蘖㔗-D 敘垬噘嘖滇幘敘晵㔗
檪昄扞蘸嗘婺婥橬滯䇞庖枕劉䔇 INSERT 变傴(INSERT INTO table (column, ...) VALUES ...)㔗認湙嚔凚躘敵崉麂婩䚷晵垄婂襕䫘庯彽嘩闼䓉埇傖䫘庯噽垄麂 PostgreSQL 昄扞康䔇蘸嗘㔗
埻蘸嗘噘匔凹茇(蓐謾启臘䷺閘)蔯婉蘸嗘昄扞康㔗
媘䘖 pg_dumpall 启昄扞康橉媇単幋閘䔇䬽橸噞彆㔗
pg_dumpall 埇傖崇䊖蔕䬽橸䔇 PostgreSQL 䔇昄扞康嘖滇崻蔕䔇昄扞康儌婉喉櫇毕庖(䕞嬉彄 7.0)㔗套悩嘹驔襕虿誺䬽橸演昖闼幽埇傖嘪䫘認婻锬釹(套悩 pg_dumpall 崌蘖庖埇彆臘潏傸澇躥只誺嘹㔗)
嘩婺昄扞䔇婔鄘彖婺懟婻臘鄘膷庺凹茇湺臖(OID)㔗套悩嘹䔇庫䫘驔襕 OID 庖枕䔇臺(懫套婘崡髞亥溘婺䫘彄)闼幽嘪䫘認婻锬釹㔗劥彍婉庫臖嘪䫘認婻锬釹㔗
婉檪凹茇䔇欔橬溄螆䘞婺凹庫溊昄扞康㔗pg_dumpall 邻螴埏庺 ALTER OWNER 潡 SET SESSION AUTHORIZATION 臺埖傖螆䘞录傺䔇昄扞康凹茇䔇欔橬溄㔗套悩認底臔橸儖準澇橬赆轙亓䫘潙(潡蔙拖橬臔橸婺噘鄘凹茇䔇䫘潙)誊臯䔇臺儖嚔崌蘖㔗-O 锬釹儌滇婺庖螷臖臔橸埇傖赆傂嘘䫘潙敵崉幽婫儖臔橸婺凹茇䔇欔橬溄蕋庽臖锬釹毺垔䔇䫘潙㔗
埻膷庺凹茇垔幬(昇嚟)婉膷庺昄扞㔗
毺垔噿閺蓥埏単施驔襕䫘彄䔇轙亓䫘潙劉㔗垄埻橬嘪䫘庖 --disable-triggers 䔇施唍欉橬嘌巉㔗婔轸愙喕婋橔喘婉襕膷噖認婻埗昄蔯滇䫘轙亓䫘潙劇媘䫘潊䔇臔橸㔗
毺垔喖嘍昇嚟㔗認湙儖傴 pg_dumpall 膷庺臥䂖䔇凹茇臇濘傖埪蘸嗘桺傽䔇劇啩施閘启誕庥媇敇彄湺庖髍臇婪㔗垄儖劯施劇䫘 pg_dump 䔇喖嘍膷庺㔗
䥕溵蘸嗘螪閞溄鍊(grant/revoke 变傴)
認婻锬釹噿閺嘪䫘䆯噄严䘯垔庘昄嘷㔗嚺彽垄傸䫘 SQL 湺庖䔇庖严婾臺濘䔇嚘埙寙啘㔗
認婻锬釹埻滇启录傺備橬昄扞䔇蘸嗘䕩噿㔗垄只臬 pg_dumpall 寙劆婘敵崉昄扞施婘施噿閺䕞湺臘婪蓥埏単䔇变傴㔗套悩婘臘婪橬埗䙓垯昘攓演昖潡蔙噽垄蓥埏単蔯敵崉昄扞䔇施唍婉愿麉蘘傡傸闼幽儌庫臖嘪䫘認婻锬釹㔗
䕞嬉婺 --disable-triggers 埏庺䔇变傴媙釂傖轙亓䫘潙準欓臯㔗啹溴嘹庫臖劯施䫘 -S 弄滯婔婻轙亓䫘潙劉潡蔙橔喘滇䫘婔婻轙亓䫘潙䔇躆傘準劇媘認婻䫘潊䔇臔橸㔗
膷庺严劽 SQL 湺庖䔇 SET SESSION AUTHORIZATION 变傴蔯婉滇 ALTER OWNER 变傴㔗認湙傴蘸嗘敘媹严劽湺庖嘖滇套悩蘸嗘桺傽婺䔇凹茇䔇寖埾橬底閞鵻闼幽埇脘婉脘溼䇞敵崉㔗
婋麵䔇变傴臯埗昄毓彽昄扞康䔇誂毖埗昄㔗
毺垔誊臯橉媇単䔇婂橺劉㔗套悩昄唚傖桩溹嚔崘彍赆䫘嘩彄 Unix 嘘喖毖庖䔇虇冇㔗䚺䩕傯 PGHOST 䯇嵄埻麟婺诙埡(套悩螆䘞庖䔇臺)劥彍儺臘婔婻 Unix 嘘喖毖庖誂毖㔗
毺垔橉媇単溼婘冥劸䔇 TCP 䆇埼潡橸婄 Unix 嘘喖毖庖桺傽䔇欷匘(柟誄严)㔗䚺䩕嘪䫘 PGPORT 䯇嵄埻麟(套悩螆䘞庖䔇臺)劥彍䚡臏施䔇䚺䩕唚㔗
誂毖䔇䫘潙劉
嚺彽埼傴柊䴺㔗套悩橉媇単驔襕埼傴螴臕闼幽認婻媘嘩庫臖躻媘埏䫘㔗
啹婺 pg_dumpall 婘喙鄘脄䫘 pg_dump 欔傖婔底自桺媇敇埇傖埗蔄 pg_dump
敵崉垯幋劯傺螞婘懟婻噾敵崉䔇凹茇婪誊臯 ANALYZE 㔗認湙嚻寡単儌埇傖冖彄橬䫘䔇䂘螇㔗嘹幘埇傖䫘 vacuumdb -a -z 橙䊖欔橬昄扞康㔗
pg_dumpall 襕挗欔橬驔襕䔇臘䷺閘䕞嘘婘誕臯敵崉幋嬉儌媙釂庻婘劥彍婘麂湺庖嘉䘞录傺昄扞康儖嚔崌蘖㔗