當前位置:首頁 » 操作系統 » linuxoracle導入

linuxoracle導入

發布時間: 2022-04-02 23:02:21

linux中怎麼實現導入導出oracle資料庫

exp和imp

1. 獲取幫助
imp help=y
2. 導入一個完整資料庫
imp system/manager file=bible_db log=dible_db full=y ignore=y
3. 導入一個或一組指定用戶所屬的全部表、索引和其他對象
imp system/manager file=seapark log=seapark fromuser=seapark
imp system/manager file=seapark log=seapark fromuser=(seapark,amy,amyc,harold)
4. 將一個用戶所屬的數據導入另一個用戶
imp system/manager file=tank log=tank fromuser=seapark touser=seapark_
imp system/manager file=tank log=tank fromuser=(seapark,amy)
touser=(seapark1, amy1)
5. 導入一個表
imp system/manager file=tank log=tank fromuser=seapark TABLES=(a,b)
6. 從多個文件導入
imp system/manager file=(paycheck_1,paycheck_2,paycheck_3,paycheck_4)
log=paycheck, filesize=1G full=y
7. 使用參數文件
imp system/manager parfile=bible_tables.par
bible_tables.par參數文件:
#Import the sample tables used for the Oracle8i Database Administrator's
Bible. fromuser=seapark touser=seapark_ file=seapark log=seapark_import
8. 增量導入
imp system./manager inctype= RECTORE FULL=Y FILE=A
-------------------------------------------------------------------------------------------------------------------------------------------
1. 獲取幫助
exp help=y

2. 導出一個完整資料庫
exp system/manager file=bible_db log=dible_db full=y

3. 導出資料庫定義而不導出數據
exp system/manager file=bible_db log=dible_db full=y rows=n

4. 導出一個或一組指定用戶所屬的全部表、索引和其他對象
exp system/manager file=seapark log=seapark owner=seapark
exp system/manager file=seapark log=seapark owner=(seapark,amy,amyc,harold)
注意:在導出用戶時,盡管已經得到了這個用戶的所有對象,但是還是不能得到這些對象引用的任何同義詞。解決方法是用以下的sql*Plus命令創建一個腳本文件,運行這個腳本文件可以獲得一個重建seapark所屬對象的全部公共同義詞的可執行腳本,然後在目標資料庫上運行該腳本就可重建同義詞了。

SET LINESIZE 132
SET PAGESIZE 0
SET TRIMSPOOL ON
SPOOL c:\seapark.syn
SELECT 'Create public synonym '||synonym_name
||' for '||table_owner||'.'||table_name||';'
FROM dba_synonyms
WHERE table_owner = 'SEAPARK' AND owner = 'PUBLIC';
SPOOL OFF

5. 導出一個或多個指定表
exp seapark/seapark file=tank log=tank tables=tank
exp system/manager file=tank log=tank tables=seapark.tank
exp system/manager file=tank log=tank tables=(seapark.tank,amy.artist)

6. 估計導出文件的大小
全部表總位元組數:
SELECT sum(bytes)
FROM dba_segments
WHERE segment_type = 'TABLE';

seapark用戶所屬表的總位元組數:
SELECT sum(bytes)
FROM dba_segments
WHERE owner = 'SEAPARK'
AND segment_type = 'TABLE';

seapark用戶下的aquatic_animal表的位元組數:
SELECT sum(bytes)
FROM dba_segments
WHERE owner = 'SEAPARK'
AND segment_type = 'TABLE'
AND segment_name = 'AQUATIC_ANIMAL';

7. 導出表數據的子集(oracle8i以上)
NT系統:

exp system/manager query='Where salad_type='FRUIT'' tables=amy.salad_type
file=fruit log=fruit
UNIX系統:

exp system/manager query=\"Where salad_type=\'FRUIT\'\" tables=amy.salad_type
file=fruit log=fruit

8. 用多個文件分割一個導出文件
exp system/manager
file=(paycheck_1,paycheck_2,paycheck_3,paycheck_4)
log=paycheck, filesize=1G tables=hr.paycheck

9. 使用參數文件
exp system/manager parfile=bible_tables.par
bible_tables.par參數文件:

#Export the sample tables used for the Oracle8i Database Administrator's Bible.
file=bible_tables
log=bible_tables
tables=(
amy.artist
amy.books
seapark.checkup
seapark.items
)

10. 增量導出
「完全」增量導出(complete),即備份整個資料庫
exp system/manager inctype=complete file=990702.dmp
「增量型」增量導出(incremental),即備份上一次備份後改變的數據
exp system/manager inctype=incremental file=990702.dmp
「累計型」增量導出(cumulative),即備份上一次「完全」導出之後改變的數據
exp system/manager inctype=cumulative file=990702.dmp

⑵ linux下怎麼用命令導入oracle 備份.del格式文件

1、.del格式文件是DB2導出的定界ASCII文件:
db2 => EXPORT TO emp.del OF DEL SELECT * FROM emp
2、[db2inst1@server9 ~]$ vi emp.del
"000010","CHRISTINE","I","HAAS","A00","3978",19950101,"PRES ",18,"F",19630824,+0152750.00,+0001000.00,+0004220.00
"000020","MICHAEL","L","THOMPSON","B01","3476",20031010,"MANAGER ",18,"M",19780202,+0094250.00,+0000800.00,+0003300.00
3、如果你要在db2導入.del文件
db2 import from myfile.del of del insert into mytable
4、如果你要在oracle導入.del文件
你需要根據格式create table,用Toad for oracle 或者Navicat for oracle導入txt即可。

⑶ 如何將Oracle Linux下的資料庫完整的導入windows下

一、設置Linux電腦字元集,使其跟電腦上的Oracle資料庫字元集一致;
在Linux命令行界面,
查詢Oracle資料庫字元集:
select * from nls_database_parameters t where t.parameter=』NLS_CHARACTERSET』;
查詢結果:ZHS16CGB231280

然後vi /home/oracle/.bash_profile
export NLS_LANG=american_america.ZHS16CGB231280
source /home/oracle/.bash_profile

二、導出屬於wcall用戶的Oracle資料庫
exp wcall/wcall@eoss file=wcall.dmp owner=wcall; //導出資料庫

三、在Windows中安裝Oracle.10g.for.Windows,(示例中資料庫安裝在D盤,如果按照在其他磁碟,下面創建表空間的時候,需要做相應的修改)然後創建資料庫eoss,注意安裝的資料庫字元集要跟原來資料庫的相同。然後打開SQLPLUS,用system帳戶登陸後創建用戶wcall。

create user wcall identified by wcall; //創建用戶
GRANT CREATE USER,DROP USER,ALTER USER ,CREATE ANY VIEW ,
DROP ANY VIEW,EXP_FULL_DATABASE,IMP_FULL_DATABASE,
DBA,CONNECT,RESOURCE,CREATE SESSION TO wcall; //授予許可權
create tablespace CC_CALL
logging
datafile 'D:\oracle\proct\10.1.0\Db_1\cc.dbf'
size 32m
autoextend on
next 32m maxsize 2048m
extent management local; //創建表空間CC_CALL
create tablespace CC_CALL_HIS
logging
datafile 'D:\oracle\proct\10.1.0\Db_1\cc_his.dbf'
size 32m
autoextend on
next 32m maxsize 2048m
extent management local; //創建表空間CC_CALL_HIS

四、導入資料庫
IMP wcall/wcall@eoss fromuser=wcall touser=wcall file=wcall.dmp STATISTICS =none;

⑷ linux下怎麼用exp和imp導出和導入指定的oracle資料庫表

導入導出與歸不歸檔沒有關系

用oracle用戶命令行下輸入 exp scott/tiger file='保存路徑' full=y 這樣就可以全庫導出

還有一個問題是scott用戶不定要解鎖,否則會無法連接資料庫
解鎖命令是sqlplus 下的輸入alter user scott account unlock;

⑸ 求教linux 下oracle數據的導入導出方法詳細步驟

求教linux 下oracle數據的導入導出方法詳細步驟
一. 導出工具 exp

1. 它是操作系統下一個可執行的文件 存放目錄/ORACLE_HOME/bin

exp導出工具將資料庫中數據備份壓縮成一個二進制系統文件.可以在不同OS間遷移

它有三種模式:
a. 用戶模式: 導出用戶所有對象以及對象中的數據;
b. 表模式: 導出用戶所有表或者指定的表;
c. 整個資料庫: 導出資料庫中所有對象。

2. 導出工具exp互動式命令行方式的使用的例子

$exp test/test123@appdb
Enter array fetch buffer size: 4096 > 回車
Export file: expdat.dmp > m.dmp 生成導出的文件名
(1)E(ntire database), (2)U(sers), or (3)T(ables): (2)U > 3
Export table data (yes/no): yes > 回車
Compress extents (yes/no): yes > 回車
Export done in ZHS16GBK character set and ZHS16GBK NCHAR character set
About to export specified tables via Conventional Path ...
Table(T) or Partition(T:P) to be exported: (RETURN to quit) > cmamenu 要導出的表名
. . exporting table CMAMENU 4336 rows exported
Table(T) or Partition(T:P) to be exported: (RETURN to quit) >要導出的表名n
Table(T) or Partition(T:P) to be exported: (RETURN to quit) > 回車
Export terminated successfully without warnings.

3. 導出工具exp非互動式命令行方式的例子

$exp scott/tiger tables=(emp,dept) file=/directory/scott.dmp grants=y

說明:把scott用戶里兩個表emp,dept導出到文件/directory/scott.dmp

$exp scott/tiger tables=emp query=\"where job=\'salesman\' and sal\<1600\" file=/directory/scott2.dmp

說明:在exp裡面加上導出emp的查詢條件job='salesman' and sal<1600

(但我個人很少這樣用,還是把滿足條件的記錄生成臨時表後,再exp會方便一些)

$exp parfile=username.par
file=/directory1/username_1.dmp,/directory1/username_2.dmp
filesize=2000M log=/directory2/username_exp.log

參數文件username.par內容
userid=username/userpassword
buffer=8192000
compress=n
grants=y

說明:username.par為導出工具exp用的參數文件,裡面具體參數可以根據需要去修改

filesize指定生成的二進制備份文件的最大位元組數

(可用來解決某些OS下2G物理文件的限制及加快壓縮速度和方便刻歷史數據光碟等)

二.導入工具 imp

1. 它是操作系統下一個可執行的文件 存放目錄/ORACLE_HOME/bin

imp導入工具將EXP形成的二進制系統文件導入到資料庫中.

它有三種模式:
a. 用戶模式: 導出用戶所有對象以及對象中的數據;
b. 表模式: 導出用戶所有表或者指定的表;
c. 整個資料庫: 導出資料庫中所有對象。

只有擁有IMP_FULL_DATABASE和DBA許可權的用戶才能做整個資料庫導入

imp步驟:
(1) create table (2) insert data (3) create index (4) create triggers,constraints

2.導入工具imp互動式命令行方式的例子
$ imp
Import: Release 8.1.6.0.0 - Proction on 星期五 12月 7 17:01:08 2001
(c) Copyright 1999 Oracle Corporation. All rights reserved.
用戶名: test
口令:****
連接到: Oracle8i Enterprise Edition Release 8.1.6.0.0 - 64bit Proction
With the Partitioning option
JServer Release 8.1.6.0.0 - Proction
導入文件: expdat.dmp> /tmp/m.dmp
輸入插入緩沖區大小(最小為 8192 ) 30720>
經由常規路徑導出由EXPORT:V08.01.06創建的文件
警告: 此對象由 TEST 導出, 而不是當前用戶
已經完成ZHS16GBK字元集和ZHS16GBK NCHAR 字元集中的導入
只列出導入文件的內容(yes/no):no>
由於對象已存在, 忽略創建錯誤(yes/no):no> yes
導入許可權(yes/no):yes>
導入表數據(yes/no):yes>
導入整個導出文件(yes/no):no> yes
. 正在將TEST的對象導入到 SCOTT
. . 正在導入表 "CMAMENU" 4336行被導入
成功終止導入,但出現警告。

3.導入工具imp非互動式命令行方式的例子

$ imp system/manager fromuser=jones tables=(accts)
$ imp system/manager fromuser=scott tables=(emp,dept)
$ imp system/manager fromuser=scott touser=joe tables=emp
$ imp scott/tiger file = expdat.dmp full=y
$ 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.log
$ imp system/manager parfile=params.dat
params.dat 內容
file=dba.dmp show=n ignore=n grants=y fromuser=scott tables=(dept,emp)

4.導入工具imp可能出現的問題

(1) 資料庫對象已經存在
一般情況, 導入數據前應該徹底刪除目標數據下的表, 序列, 函數/過程,觸發器等;
資料庫對象已經存在, 按預設的imp參數, 則會導入失敗
如果用了參數ignore=y, 會把exp文件內的數據內容導入
如果表有唯一關鍵字的約束條件, 不合條件將不被導入
如果表沒有唯一關鍵字的約束條件, 將引起記錄重復

(2) 資料庫對象有主外鍵約束
不符合主外鍵約束時, 數據會導入失敗
解決辦法: 先導入主表, 再導入依存表
disable目標導入對象的主外鍵約束, 導入數據後, 再enable它們
(3) 許可權不夠
如果要把A用戶的數據導入B用戶下, A用戶需要有imp_full_database許可權

(4) 導入大表( 大於80M ) 時, 存儲分配失敗
默認的EXP時, compress = Y, 也就是把所有的數據壓縮在一個數據塊上.
導入時, 如果不存在連續一個大數據塊, 則會導入失敗.
導出80M以上的大表時, 記得compress= N, 則不會引起這種錯誤.

(5) imp和exp使用的字元集不同
如果字元集不同, 導入會失敗, 可以改變unix環境變數或者NT注冊表裡NLS_LANG相關信息.
導入完成後再改回來.

(6) imp和exp版本不能往上兼容
imp可以成功導入低版本exp生成的文件, 不能導入高版本exp生成的文件
根據情況我們可以用
$ imp username/password@connect_string
說明: connect_string 是在/ORACLE_HOME/network/admin/tnsnames.ora
定義的本地或者遠端資料庫的名稱
注意事項:
UNIX: /etc/hosts 要定義本地或者遠端資料庫伺服器的主機名
win98: windows\hosts 和IP地址的對應關系

win2000: winnt\system32\drivers\etc\hosts

⑹ oracle導入導出數據怎麼弄在Linux下!裝了oracle11G 為什麼imp命令不能用

有報錯截圖嗎
應該是沒有配置環境變數
增加PATH
PATH=$ORACLE_HOME/bin:$PATH

⑺ 如何在虛擬機中Linux下導入oracle

這和在實體機中做沒有區別啊

熱點內容
怎麼查看安卓機用多久 發布:2024-09-27 19:13:03 瀏覽:322
掛抖音腳本 發布:2024-09-27 19:12:27 瀏覽:99
python字元串不相等 發布:2024-09-27 19:04:00 瀏覽:37
和目攝像頭連接伺服器失敗為什麼 發布:2024-09-27 19:02:05 瀏覽:301
朗讀微腳本 發布:2024-09-27 19:00:18 瀏覽:243
c語言與或if 發布:2024-09-27 18:47:22 瀏覽:305
河南聯通伺服器升級雲主機 發布:2024-09-27 18:46:33 瀏覽:50
外發密碼多少 發布:2024-09-27 18:42:48 瀏覽:10
什麼牌子的安卓手機有耳機彈窗 發布:2024-09-27 18:29:26 瀏覽:515
sql別名的使用 發布:2024-09-27 18:24:34 瀏覽:366