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