zhyiwww
          用平實(shí)的筆,記錄編程路上的點(diǎn)點(diǎn)滴滴………
          posts - 536,comments - 394,trackbacks - 0
          用postgres 的pg_dump可以實(shí)現(xiàn)從從postgres數(shù)據(jù)庫(kù)中導(dǎo)出數(shù)據(jù)。
          [1]只導(dǎo)出所有對(duì)象的數(shù)據(jù)庫(kù)結(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ù)庫(kù)版本
          ?? -C 包括創(chuàng)建數(shù)據(jù)庫(kù)的語(yǔ)句
          ?? -E 設(shè)定導(dǎo)出數(shù)據(jù)的編碼
          ?? -n 是Scheme的名稱
          ?? -U 是用戶名稱
          ?? -h 是數(shù)據(jù)庫(kù)服務(wù)器的名稱
          ?? -W 是用強(qiáng)制密碼驗(yàn)證

          ?? -s 只導(dǎo)出數(shù)據(jù)庫(kù)結(jié)構(gòu)

          ?? 最后一個(gè)參數(shù),當(dāng)然就是數(shù)據(jù)庫(kù)名稱了

          [2]導(dǎo)出所有對(duì)象的數(shù)據(jù)庫(kù)結(jié)構(gòu)和數(shù)據(jù)
          ?? C:\>pg_dump -f DDDDDD.sql -i? -C -E UTF8 -n public? -U portal -h localhost -W portal
          ?? 沒(méi)有-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ù)庫(kù)myportal 不存在,要先創(chuàng)建數(shù)據(jù)庫(kù)
          ?? createdb -U postgres -h 192.168.1.233? myportal
          ?? 然后再執(zhí)行上面的導(dǎo)入語(yǔ)句就可以了。
          [2]psql -hlocalhost -U myuser -d myportal < DDDDDD.sql
          ?? 執(zhí)行語(yǔ)句導(dǎo)入數(shù)據(jù)就可以了。


          |----------------------------------------------------------------------------------------|
                                     版權(quán)聲明  版權(quán)所有 @zhyiwww
                      引用請(qǐng)注明來(lái)源 http://www.aygfsteel.com/zhyiwww   
          |----------------------------------------------------------------------------------------|
          posted on 2008-11-17 12:05 zhyiwww 閱讀(4878) 評(píng)論(1)  編輯  收藏 所屬分類: database

          FeedBack:
          # re: postgres實(shí)現(xiàn)導(dǎo)出和導(dǎo)入[未登錄](méi)
          2009-05-12 11:53 | 學(xué)習(xí)者
          為什么 pg_dump 用UTF8導(dǎo)出,psql 導(dǎo)入亂碼呀  回復(fù)  更多評(píng)論
            
          主站蜘蛛池模板: 满洲里市| 无极县| 宕昌县| 玛纳斯县| 昌平区| 南宁市| 靖州| 平定县| 香格里拉县| 革吉县| 柳林县| 文安县| 平远县| 新干县| 阿瓦提县| 清流县| 临江市| 木兰县| 高雄县| 密山市| 皮山县| 老河口市| 阿坝县| 兴山县| 常州市| 东方市| 龙游县| 成安县| 兴业县| 客服| 瑞金市| 阿鲁科尔沁旗| 武乡县| 信阳市| 天柱县| 繁峙县| 鄂托克旗| 新泰市| 康定县| 砚山县| 平谷区|