用postgres 的pg_dump可以實現(xiàn)從從postgres數(shù)據(jù)庫中導出數(shù)據(jù)。
[1]只導出所有對象的數(shù)據(jù)庫結(jié)構(gòu)
?? C:\>pg_dump -f DDDDDD.sql -i? -C -E UTF8 -n public -s? -U portal -h localhost -W portal
?? -i 是為了兼容數(shù)據(jù)庫版本
?? -C 包括創(chuàng)建數(shù)據(jù)庫的語句
?? -E 設(shè)定導出數(shù)據(jù)的編碼
?? -n 是Scheme的名稱
?? -U 是用戶名稱
?? -h 是數(shù)據(jù)庫服務(wù)器的名稱
?? -W 是用強制密碼驗證
?? -s 只導出數(shù)據(jù)庫結(jié)構(gòu)
?? 最后一個參數(shù),當然就是數(shù)據(jù)庫名稱了
[2]導出所有對象的數(shù)據(jù)庫結(jié)構(gòu)和數(shù)據(jù)
?? C:\>pg_dump -f DDDDDD.sql -i? -C -E UTF8 -n public? -U portal -h localhost -W portal
?? 沒有-s參數(shù)
[3]只導出所有的表數(shù)據(jù)
?? C:\>pg_dump -f DDDDDD.sql -i -a -C -E UTF8 -n public? -U portal -h localhost -W portal
?? -a 只導出數(shù)據(jù)
數(shù)據(jù)導入
[1]c:\psql -f DDDDDD.sql -h 192.168.1.233 -U myuser -W myportal
?? 執(zhí)行就可以實現(xiàn)導入了。
?? 如果數(shù)據(jù)庫myportal 不存在,要先創(chuàng)建數(shù)據(jù)庫
?? createdb -U postgres -h 192.168.1.233? myportal
?? 然后再執(zhí)行上面的導入語句就可以了。
[2]psql -hlocalhost -U myuser -d myportal < DDDDDD.sql
?? 執(zhí)行語句導入數(shù)據(jù)就可以了。
|----------------------------------------------------------------------------------------|
版權(quán)聲明 版權(quán)所有 @zhyiwww
引用請注明來源 http://m.tkk7.com/zhyiwww
|----------------------------------------------------------------------------------------|
posted on 2008-11-17 12:05
zhyiwww 閱讀(4873)
評論(1) 編輯 收藏 所屬分類:
database