oracle数据库表的导入导出cmd命令大全
在實(shí)際的項(xiàng)目開發(fā)中經(jīng)常會遇到導(dǎo)入導(dǎo)出oracle數(shù)據(jù)庫中的表,以下是常用的一些cmd命令:
一、數(shù)據(jù)表的導(dǎo)出
1 將數(shù)據(jù)庫TEST完全導(dǎo)出,用戶名system 密碼manager 導(dǎo)出到D:daochu.dmp中
exp??file=d:daochu.dmp full=y ?或者(exp RRS/RRS@192.168.1.80 file=daochu.dmp full=y )這是將表全部導(dǎo)出,如果只想導(dǎo)出RRS表則:
exp RRS/RRS@192.168.1.80(如果在服務(wù)器導(dǎo)出:ORCL) file=daochu.dmp owner=(RRS) (無數(shù)據(jù)的表導(dǎo)不出);
這是11gR2的新特性,首先alter system set deferred_segment_creation=false; 然后select 'alter table '||table_name||' allocate extent;' from user_tables where num_rows=0 查詢所有空數(shù)據(jù)表,執(zhí)行
分配segment,然后再導(dǎo)出就可以了。
?
(expdp?RRS/RRS@192.168.1.80 dumpfile=daochu.dmp)導(dǎo)出數(shù)據(jù)庫,路徑必須app/...
2 將數(shù)據(jù)庫中system用戶與sys用戶的表導(dǎo)出
????exp username/password file=d:aa.dmp owner=username;//導(dǎo)出某用戶的表
exp??file=d:daochu.dmp owner=(system,sys)
(impdp?RRS/RRS@192.168.1.80 dumpfile=daochu.dmp)導(dǎo)入數(shù)據(jù)庫
3 將數(shù)據(jù)庫中的表inner_notify、notify_staff_relat導(dǎo)出
exp file= d:data ewsmgnt.dmp tables=(inner_notify,notify_staff_relat)
4 將數(shù)據(jù)庫中的表table1中的字段filed1以"00"打頭的數(shù)據(jù)導(dǎo)出
exp file=d:daochu.dmp tables=(table1) query=" where filed1 like '00%'"
二、數(shù)據(jù)表的導(dǎo)入操作
1 將D:daochu.dmp 中的數(shù)據(jù)導(dǎo)入 TEST數(shù)據(jù)庫中。
imp file=d:daochu.dmp
imp??full=y file= d:data ewsmgnt.dmp ignore=y
上面可能有點(diǎn)問題,因?yàn)橛械谋硪呀?jīng)存在,然后它就報(bào)錯(cuò),對該表就不進(jìn)行導(dǎo)入。
在后面加上 ignore=y 就可以了。
2 將d:daochu.dmp中的表table1 導(dǎo)入
imp file=d:daochu.dmp tables=(table1)
基本上上面的導(dǎo)入導(dǎo)出夠用了。不少情況要先是將表徹底刪除,然后導(dǎo)入。
三、操作注意:
操作者要有足夠的權(quán)限,權(quán)限不夠它會提示。一般賦予dba最大權(quán)限即可。
數(shù)據(jù)庫時(shí)可以連上的。可以用tnsping TEST 來獲得數(shù)據(jù)庫TEST能否連上。
1、給用戶增加導(dǎo)入數(shù)據(jù)權(quán)限的操作
第一,啟動cmd
第二,以/as sysdba登陸數(shù)據(jù)庫
第三,create user 用戶名?identified by ?密碼
????可以直接賦予最大權(quán)限:grant dba to 用戶名
????賦予基本權(quán)限:grant connect,resource to 用戶
第四,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 用戶名字
執(zhí)行示例:
F:WorkOracle_Dataackup>imp userid=test/test full=y file=inner_notify.dmp
屏幕顯示
Import: Release 8.1.7.0.0 - Production on 星期四 2月 16 16:50:05 2006
(c) Copyright 2000 Oracle Corporation. All rights reserved.
連接到: Oracle8i Enterprise Edition Release 8.1.7.0.0 - Production
With the Partitioning option
JServer Release 8.1.7.0.0 - Production
經(jīng)由常規(guī)路徑導(dǎo)出由EXPORT:V08.01.07創(chuàng)建的文件
已經(jīng)完成ZHS16GBK字符集和ZHS16GBK NCHAR 字符集中的導(dǎo)入
導(dǎo)出服務(wù)器使用UTF8 NCHAR 字符集 (可能的ncharset轉(zhuǎn)換)
. 正在將AICHANNEL的對象導(dǎo)入到 AICHANNEL
. . 正在導(dǎo)入表??????????????????"INNER_NOTIFY"??????????4行被導(dǎo)入
準(zhǔn)備啟用約束條件...
成功終止導(dǎo)入,但出現(xiàn)警告。
附錄二:
Oracle 不允許直接改變表的擁有者, 利用Export/Import可以達(dá)到這一目的.
先建立import9.par,
然后,使用時(shí)命令如下:imp parfile=/filepath/import9.par
例 import9.par 內(nèi)容如下:
FROMUSER=TGPMS
TOUSER=TGPMS2?????(注:把表的擁有者由FROMUSER改為TOUSER,FROMUSER和TOUSER的用戶可以不同)
ROWS=Y
INDEXES=Y
GRANTS=Y
CONSTRAINTS=Y
BUFFER=409600
file==/backup/ctgpc_20030623.dmp
log==/backup/import_20030623.log
轉(zhuǎn)載于:https://www.cnblogs.com/cyl048/p/6002782.html
總結(jié)
以上是生活随笔為你收集整理的oracle数据库表的导入导出cmd命令大全的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: debian/deepin 15.3 1
- 下一篇: MYSQL数据库导入出错:#1046 -