导入导出sql语句

--expdp 导出
create directory dpdata1 as 'D:\test\dump';--创建目录
grant read,write on directory dpdata1 to scott;--赋予权限
select * from dba_directories;--查询目录
--要在C盘创建test\dump文件夹
--按用户导出
expdp riskdm/riskdm@RISKDM directory=XMLDIR  dumpfile=riskdm1204.dmp schemas=riskdm logfile=riskdm1204.log
--按表名导出
expdp scott/scott directory=dpdata2 dumpfile=tables.dmp logfile=tables.log tables=dept,emp
--按查询条件导出
expdp scott/scott directory=dpdata2 dumpfile=tables.dmp logfile=tables.log tables=emp query='where deptno=20'
--导出表空间
expdp system/manager directory=dpdata2 dumpfile=tablespace.dmp tablespace=temp,example
--导出数据库
expdp riskdm/riskdm@RISKDM directory=XMLDIR dumpfile=riskdm.dmp logfile=riskdm.log full=y
--查看正在运行的expdp
SELECT * FROM Dba_Datapump_Jobs 
expdp riskdm/riskdm@RISKDM attach=SYS_EXPORT_FULL_01
stop_job--停止该进程
kill—job--杀死该进程


--impdp 导入
--导入到指定用户下
impdp riskdm/riskdm@RISKDMTEST directory=dpdata2 dumpfile=riskdm0222.dmp schemas=riskdm
--导入表
impdp scott/scott directory=dpdata2 dumpfile=tables.dmp tables=scott.dept remap_schema=scott:system
--导入表空间
impdp system/manager directory=dpdata2 dumpfile=tablespace.dmp tablespace=example
--导入数据库
impdp riskdm/riskdm@orcl directory=DUMP_DIR dumpfile=riskdm1204.dmp full=y




exp导出
1) 将数据库orcl完全导出
exp riskdm/riskdm@RISKDM file=d:\orcl.dmp full=y
2) 将数据库中system用户的表导出
exp system/manager@orcl file=d:\system_bak.dmp owner=system
3) 将数据库中表table1,table2导出
exp system/manager@orcl file=d:\table_bak.dmp tables=(table1,table2)
4) 将数据库中的表customer中的字段mobile以"139"开头的数据导出
exp system/manager@orcl file=d:\mobile_bak.dmp tables=customer query=\"where mobile like '139%' \"

猜你喜欢

转载自blog.csdn.net/sinat_25378929/article/details/52126687