oracle数据库总结(十七)--数据导入导出

1导出

     1.1是本地的dos命令执行的语句,导出的文件保存在17.88服务器上的dump路径下的

expdp CSDAS/[email protected]:1521/orcl schemas=CSDAS directory=dump dumpfile=csdas1711172.dmp

 

    1.2本地导出

expdp test4/test4@orcl directory=DUMP compression=all dumpfile=test40302.dmp

expdp CDPHINFO/CDPHINFO@orcl directory=DUMP  dumpfile=CDPTHINFO0620.dmp logfile=CDPHINFO0620.log compression=all  parallel=2

 

   1.3远程导出(表数据不为空)

exp cspt/[email protected]:1521/orcl file=d:\cspt1611.dmp

          导出表数据与表结构(表数据不为空)

exp fcgwt170606/[email protected]:1521/orcl file=d:\fcgwt20170607.dmp tables=(aa10)

           导出表结构(表数据为空,只需要导出表结构就行)

plsql ->工具->导出用户对象

             导出表内容

查询出所有的-->导出sql文件

 

       1.4导出数据量太大

    可考虑删除该表(drop table) 或者清除表里面的数据(Truncate,比delete删除的速度更快更彻底)

 

2导入

     2.1登录

命令进入数据库本机登录:sqlplus sys/sys as sysdba

远程登录sqlplus sys/[email protected]:1521/orcl

    2.2创建目录

create directory dump as 'd:\oracleusers\trader';//注意是单引号

    2.3创建表空间

create tablespace CDWTTD logging datafile 'D:\YHDSAPP\DBS\CDWTTD.dbf' size 500m autoextend on next 100m maxsize unlimited extent management local;

   2.4创建用户

 create user cdnt identified by cdnt default tablespace CDWTTD ; 指定默认表空间为CDWTTD

   2.5授权

grant dba,resource,connect to ta33;授予更多权限

   2.6导入

纯净的导入

impdp system/system directory=dump dumpfile=CSWT180516.dmp   remap_schema=cswt1104:cswt180518 remap_tablespace=YHDATA:users

impdp test5/test4@orcl DIRECTORY=DUMP DUMPFILE = test40302.dmp remap_schema=test4:test5 REMAP_TABLESPACE=TEST:TEST

 

imp CDPHINFO/CDPHINFO@orcl  file=E:\dc\cspt1619.dmp full=y (表里面有数据)

 

导入表结构与表内容(表里面有数据)

本地导入

在17.88上面执行的下面的语句就可以了

impdp system/system directory=dump parallel=5 dumpfile=CSDAS1711172.DMP remap_schema=CSDAS:lydas remap_tablespace=gzhf:users remap_tablespace=data:users remap_tablespace=yhdata:users remap_tablespace=yadata:users remap_tablespace=tcgjj:users remap_tablespace=lsdata:users remap_tablespace=lsgjjdata:users remap_tablespace=yhhfdata:users remap_tablespace=tsdata:users

imp testfcgwt/testfcgwt@orcl  file=d:\fcgwt20170607.dmp full=y

 

imp 自己新建的用户/新建的用户的密码  file=D:\20140227.dmp full=y ignore=y (将文件导入到我们自己新建的用户的表空间中)

导入表结构(表里面没有数据)

修改用户名以后 -->命令窗口里面运行

删除用户

drop user cdhf cascade;

删除目录
drop directory dump;

删除表空间

drop TABLESPACE tb_mshf28 including contents and datafiles;

drop tablespace fcgwt20170607 INCLUDING CONTENTS AND DATAFILES;

修改用户名和密码

alter user apps identified by 123456;

查看表空间

select username,default_tablespace from dba_users  where username='DTDA0104';

猜你喜欢

转载自blog.csdn.net/lsx2017/article/details/84838700