oracle的数据导入导出

请问Oracle提供的数据导入、导出工具是什么?现有Oracle实例orcl,用户名ccense,密码ccense,数据表Table1,Table2,数据备份在D盘根目录。请按照“表模式”“用户模式”“全库模式”分别写出导出和导入命令。

题主可以试试:
数据导出工具 expdp

expdp是服务器端工具,只能在服务器端使用,客户端可使用exp工具

expdp工具只能将导出的转储文件放在directory对象对应的目录,不能直接指定磁盘目录。因此使用expdp工具,首先建立directory对象,并且需要为数据库用户授予使用directory对象的权限

1)创建directory对象

create directory dump_dir as 'd:\dump';

2)授权

grant read,write on directory dump_dir to scott;

3)导出表

导出表是指将一个或多个表的结构及其数据存储到转储文件中。普通用户只能导出自身模式中的表。导出其他模式中的表,必须具有exp_full_database角色或dba角色权限。在导出表时,每次只能导出一个模式中的表

expdp scott/123456 directory=dump_dir dumpfile=tab.dmp tables=emp,dept //导出scott模式中的emp和dept表

4)导出模式

导出模式是指将一个或多个模式中的所有对象及数据转储到转储文件中,导出模式要求用户具有exp_full_database或dba角色权限

expdp system/123456 directory=dump_dir dumpfile=schema.dmp schemas=scott,hr

//导出scott模式和hr模式中的所有对象和数据

5)导出表空间

导出表空间是指将一个或多个表空间中的所有对象及数据转储到转储文件中。导出表空间必须有dba角色或exp_full—database角色

expdp system/123456 directory=dump_dir dumpfile=tablespace.dmp tablespaces=tbsp_1

//导出表空间tbsp_1

6)导出全数据库

导出全数据库是指将数据库中的所有对象及数据存储到转储文件中,导出数据库要求用户必须有dba角色或exp_full_database角色。注意:导出数据库时,不会导出sys,ordsys,ordplugins,ctxsys,mdsys,lbacsys以及xdb等模式中的对象

expdp system/123456 directory=dump_dir dumpfile=fulldatabase.dmp full=y

7)expdp命令参数

1.content 用户指定要导出的内容,默认值为all

content={all | data_only | metadata_only}

all: 将导出对象定义及其所有数据

data_only:只导出对象数据

metadata_only: 只导出对象定义

expdp scott/123456 directory=dump_dir dumpfile=content.dmp content=data_only

2.query 用于指定过滤导出数据的where条件

query=[schema.][table_name:] query_clause

schema: 用于指定模式名

table_name: 用于指定表名

query_clause:用于指定条件限制子句

query不能与connect=metadata_only,extimate_only,transprot_tablespaces等参数同时使用

expdp scott/123456 directory=dump_dir dumpfile=query.dmp tables=dept query='where deptno=10'

//导出dept表中编号为10的数据

3.directory 指定转储文件和日志文件所在的目录

4.dumpfile 指定转储文件的名称

5.full 指定数据库模式导出 默认为n

full={y | n}

当设置为y时,表示执行数据库导出

6.logfile 指定导出日志文件的名称,默认名称 export.log

  1. status 导出作业进程的详细状态 默认为0

status=integer

8.tables 用于指定表模式导出

tables=[schema_name.]table_name[:partition_name][...]

schema_name:用于指定模式名

table_name:用于指定要导出的表名

partition_name:用于指定要导出的分区名

9.tablespaces 指定表空间列表

exp ccense/ccense@ORCL file=d:/backup1.dmp tables=(Table1,Table2);
exp ccense/ccense@ORCL file=d:/backup2.dmp owner=ccense;
exp ccense/ccense@ORCL file=d:/backup.dmp full=y;
最后的全库模式估计要dba身份才行

数据导出工具 expdp

expdp是服务器端工具,只能在服务器端使用,客户端可使用exp工具

expdp工具只能将导出的转储文件放在directory对象对应的目录,不能直接指定磁盘目录。因此使用expdp工具,首先建立directory对象,并且需要为数据库用户授予使用directory对象的权限

1)创建directory对象

create directory dump_dir as 'd:\dump';

2)授权

grant read,write on directory dump_dir to scott;

3)导出表

PLSQL