This Is A FineDay

            BlogJava :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理 ::
            93 隨筆 :: 0 文章 :: 69 評論 :: 0 Trackbacks
          一. 導出工具 expwQeLinux聯盟
          wQeLinux聯盟
          1. 它是操作系統下一個可執行的文件 存放目錄/ORACLE_HOME/binwQeLinux聯盟
          wQeLinux聯盟
          ?? exp導出工具將數據庫中數據備份壓縮成一個二進制系統文件.可以在不同OS間遷移wQeLinux聯盟
          ?? wQeLinux聯盟
          ?? 它有三種模式:wQeLinux聯盟
          ?????? a.? 用戶模式: 導出用戶所有對象以及對象中的數據;wQeLinux聯盟
          ?????? b.? 表模式: 導出用戶所有表或者指定的表;wQeLinux聯盟
          ?????? c.? 整個數據庫: 導出數據庫中所有對象。wQeLinux聯盟
          wQeLinux聯盟
          2. 導出工具exp交互式命令行方式的使用的例子wQeLinux聯盟
          wQeLinux聯盟
          $exp test/test123@appdbwQeLinux聯盟
          Enter array fetch buffer size: 4096 > 回車wQeLinux聯盟
          Export file: expdat.dmp > m.dmp? 生成導出的文件名wQeLinux聯盟
          (1)E(ntire database), (2)U(sers), or (3)T(ables): (2)U > 3wQeLinux聯盟
          Export table data (yes/no): yes > 回車wQeLinux聯盟
          Compress extents (yes/no): yes > 回車wQeLinux聯盟
          Export done in ZHS16GBK character set and ZHS16GBK NCHAR character setwQeLinux聯盟
          About to export specified tables via Conventional Path ...wQeLinux聯盟
          Table(T) or Partition(T:P) to be exported: (RETURN to quit) > cmamenu? 要導出的表名wQeLinux聯盟
          . . exporting table??????????????????????? CMAMENU?????? 4336 rows exportedwQeLinux聯盟
          Table(T) or Partition(T:P) to be exported: (RETURN to quit) >要導出的表名nwQeLinux聯盟
          Table(T) or Partition(T:P) to be exported: (RETURN to quit) > 回車wQeLinux聯盟
          Export terminated successfully without warnings. wQeLinux聯盟
          wQeLinux聯盟
          3. 導出工具exp非交互式命令行方式的例子wQeLinux聯盟
          wQeLinux聯盟
          $exp scott/tiger tables=(emp,dept) file=/directory/scott.dmp grants=ywQeLinux聯盟
          wQeLinux聯盟
          說明:把scott用戶里兩個表emp,dept導出到文件/directory/scott.dmpwQeLinux聯盟
          wQeLinux聯盟
          $exp scott/tiger tables=emp query=\"where job=\'salesman\' and sal\<1600\" file=/directory/scott2.dmpwQeLinux聯盟
          wQeLinux聯盟
          說明:在exp里面加上導出emp的查詢條件job='salesman' and sal<1600wQeLinux聯盟
          ??? wQeLinux聯盟
          ??? (但我個人很少這樣用,還是把滿足條件的記錄生成臨時表后,再exp會方便一些)wQeLinux聯盟
          wQeLinux聯盟
          $exp parfile=username.par file=/directory1/username_1.dmp,/directory1/username_2.dmp filesize=2000M log=/directory2/username_exp.logwQeLinux聯盟
          wQeLinux聯盟
          參數文件username.par內容wQeLinux聯盟
          userid=username/userpasswordwQeLinux聯盟
          buffer=8192000wQeLinux聯盟
          compress=nwQeLinux聯盟
          grants=ywQeLinux聯盟
          wQeLinux聯盟
          說明:username.par為導出工具exp用的參數文件,里面具體參數可以根據需要去修改wQeLinux聯盟
          wQeLinux聯盟
          ???? filesize指定生成的二進制備份文件的最大字節數wQeLinux聯盟
          ???? wQeLinux聯盟
          ???? (可用來解決某些OS下2G物理文件的限制及加快壓縮速度和方便刻歷史數據光盤等)wQeLinux聯盟
          wQeLinux聯盟
          二.導入工具 impwQeLinux聯盟
          wQeLinux聯盟
          1. 它是操作系統下一個可執行的文件 存放目錄/ORACLE_HOME/binwQeLinux聯盟
          wQeLinux聯盟
          imp導入工具將EXP形成的二進制系統文件導入到數據庫中.wQeLinux聯盟
          wQeLinux聯盟
          ?? 它有三種模式:wQeLinux聯盟
          ?????? a.? 用戶模式: 導出用戶所有對象以及對象中的數據;wQeLinux聯盟
          ?????? b.? 表模式: 導出用戶所有表或者指定的表;wQeLinux聯盟
          ?????? c.? 整個數據庫: 導出數據庫中所有對象。wQeLinux聯盟
          ?????? wQeLinux聯盟
          ?? 只有擁有IMP_FULL_DATABASE和DBA權限的用戶才能做整個數據庫導入wQeLinux聯盟
          ?? wQeLinux聯盟
          ?? imp步驟:wQeLinux聯盟
          ?? (1) create table? (2) insert data? (3) create index (4) create triggers,constraintswQeLinux聯盟
          wQeLinux聯盟
          2.導入工具imp交互式命令行方式的例子wQeLinux聯盟
          $ impwQeLinux聯盟
          Import: Release 8.1.6.0.0 - Production on 星期五 12月 7 17:01:08 2001wQeLinux聯盟
          (c) Copyright 1999 Oracle Corporation.? All rights reserved.wQeLinux聯盟
          用戶名:? testwQeLinux聯盟
          口令:****wQeLinux聯盟
          連接到: Oracle8i Enterprise Edition Release 8.1.6.0.0 - 64bit ProductionwQeLinux聯盟
          With the Partitioning optionwQeLinux聯盟
          JServer Release 8.1.6.0.0 - ProductionwQeLinux聯盟
          導入文件: expdat.dmp> /tmp/m.dmpwQeLinux聯盟
          輸入插入緩沖區大小(最小為 8192 ) 30720>wQeLinux聯盟
          經由常規路徑導出由EXPORT:V08.01.06創建的文件wQeLinux聯盟
          警告: 此對象由 TEST 導出, 而不是當前用戶wQeLinux聯盟
          已經完成ZHS16GBK字符集和ZHS16GBK NCHAR 字符集中的導入wQeLinux聯盟
          只列出導入文件的內容(yes/no):no>wQeLinux聯盟
          由于對象已存在, 忽略創建錯誤(yes/no):no> yeswQeLinux聯盟
          導入權限(yes/no):yes>wQeLinux聯盟
          導入表數據(yes/no):yes>wQeLinux聯盟
          導入整個導出文件(yes/no):no> yeswQeLinux聯盟
          . 正在將TEST的對象導入到 SCOTTwQeLinux聯盟
          . . 正在導入表?????????????????????? "CMAMENU"?????? 4336行被導入wQeLinux聯盟
          成功終止導入,但出現警告。 wQeLinux聯盟
          wQeLinux聯盟
          wQeLinux聯盟
          3.導入工具imp非交互式命令行方式的例子wQeLinux聯盟
          wQeLinux聯盟
          $ imp system/manager fromuser=jones tables=(accts) wQeLinux聯盟
          $ imp system/manager fromuser=scott tables=(emp,dept) wQeLinux聯盟
          $ imp system/manager fromuser=scott touser=joe tables=emp wQeLinux聯盟
          $ imp scott/tiger file = expdat.dmp full=y wQeLinux聯盟
          $ imp scott/tiger file = /mnt1/t1.dmp show=n buffer=2048000 ignore=n commit=y grants=y full=y log=/oracle_backup/log/imp_scott.logwQeLinux聯盟
          $ imp system/manager parfile=params.dat wQeLinux聯盟
          params.dat 內容 wQeLinux聯盟
          file=dba.dmp show=n ignore=n grants=y fromuser=scott tables=(dept,emp) wQeLinux聯盟
          wQeLinux聯盟
          4.導入工具imp可能出現的問題wQeLinux聯盟
          wQeLinux聯盟
          (1) 數據庫對象已經存在wQeLinux聯盟
          一般情況, 導入數據前應該徹底刪除目標數據下的表, 序列, 函數/過程,觸發器等;? wQeLinux聯盟
          數據庫對象已經存在, 按缺省的imp參數, 則會導入失敗wQeLinux聯盟
          如果用了參數ignore=y, 會把exp文件內的數據內容導入wQeLinux聯盟
          如果表有唯一關鍵字的約束條件, 不合條件將不被導入wQeLinux聯盟
          如果表沒有唯一關鍵字的約束條件, 將引起記錄重復wQeLinux聯盟
          wQeLinux聯盟
          (2) 數據庫對象有主外鍵約束wQeLinux聯盟
          ????? 不符合主外鍵約束時, 數據會導入失敗 wQeLinux聯盟
          ????? 解決辦法: 先導入主表, 再導入依存表wQeLinux聯盟
          disable目標導入對象的主外鍵約束, 導入數據后, 再enable它們wQeLinux聯盟
          (3)? 權限不夠wQeLinux聯盟
          如果要把A用戶的數據導入B用戶下, A用戶需要有imp_full_database權限wQeLinux聯盟
          wQeLinux聯盟
          (4)? 導入大表( 大于80M ) 時, 存儲分配失敗wQeLinux聯盟
          ????? 默認的EXP時, compress = Y, 也就是把所有的數據壓縮在一個數據塊上.wQeLinux聯盟
          ????? 導入時, 如果不存在連續一個大數據塊, 則會導入失敗.wQeLinux聯盟
          ????? 導出80M以上的大表時, 記得compress= N, 則不會引起這種錯誤.wQeLinux聯盟
          wQeLinux聯盟
          (5) imp和exp使用的字符集不同wQeLinux聯盟
          ????? 如果字符集不同, 導入會失敗, 可以改變unix環境變量或者NT注冊表里NLS_LANG相關信息.wQeLinux聯盟
          ????? 導入完成后再改回來.wQeLinux聯盟
          wQeLinux聯盟
          (6) imp和exp版本不能往上兼容wQeLinux聯盟
          imp可以成功導入低版本exp生成的文件, 不能導入高版本exp生成的文件wQeLinux聯盟
          根據情況我們可以用wQeLinux聯盟
          $ imp username/password@connect_stringwQeLinux聯盟
          說明: connect_string 是在/ORACLE_HOME/network/admin/tnsnames.orawQeLinux聯盟
          ?? 定義的本地或者遠端數據庫的名稱wQeLinux聯盟
          posted on 2008-04-16 11:43 Peter Pan 閱讀(673) 評論(0)  編輯  收藏 所屬分類: DB
          主站蜘蛛池模板: 平和县| 兴山县| 临泉县| 慈利县| 岳西县| 漠河县| 孝感市| 彭州市| 中江县| 博湖县| 开江县| 保靖县| 霍林郭勒市| 盐边县| 黄山市| 武川县| 重庆市| 富锦市| 军事| 溧水县| 昌图县| 资源县| 西乌珠穆沁旗| 沁水县| 安溪县| 三门峡市| 多伦县| 南靖县| 凌云县| 大关县| 民乐县| 青田县| 通化市| 鄂托克前旗| 南部县| 新宁县| 浮梁县| 调兵山市| 肥乡县| 大邑县| 巴南区|