Oracle 表的导入与导出
周末任务:
将一个表从一个库导到另一个库
大致思路:用expdp 将表从一个实例导出 ,再用impdp将导出的 .dmp文件导入到另一个实例
1.在实例 orcl 中准备一个用于导出的表:
进入实例为orcl的数据库: export ORACLE_SID=orcl
建用户:SQL> create user orcl_user identified by 123 default tablespace table_test;
赋予dba权限:SQL> grant dba to orcl_user;
建一个directory目录:
SQL> create directory dir as '/tmp/';
把这个目录的读写权限给予用户:
SQL> grant read,write on directory dir to orcl_user;
接下来可以登录orcl_user用户建表:
sqlplus orcl_user/123
SQL> create table orcl_table as select * from dba_users;
导出:
oracle@admin ~]$ expdp orcl_user/123 dumpfile=test.dmp logfile=test.log directory=dir tables=orcl_table
Export: Release 11.2.0.4.0 - Production on Wed Dec 18 07:55:51 2019
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
Starting "ORCL_USER"."SYS_EXPORT_TABLE_01": orcl_user/******** dumpfile=test.dmp logfile=test.log directory=dir tables=orcl_table
Estimate in progress using BLOCKS method...
Processing object type TABLE_EXPORT/TABLE/TABLE_DATA
Total estimation using BLOCKS method: 64 KB
Processing object type TABLE_EXPORT/TABLE/TABLE
. . exported "ORCL_USER"."ORCL_TABLE" 14.46 KB 33 rows
Master table "ORCL_USER"."SYS_EXPORT_TABLE_01" successfully loaded/unloaded
******************************************************************************
Dump file set for ORCL_USER.SYS_EXPORT_TABLE_01 is:
/tmp/test.dmp
Job "ORCL_USER"."SYS_EXPORT_TABLE_01" successfully completed at Wed Dec 18 07:55:56 2019 elapsed 0 00:00:04
到此,导出表成功
2.在实例名为oorl的数据库中做导入的相关准备
建用户:
SQL> create user oorl_user identified by 123 default tablespace test;
赋权限(dba权限和对directory的读写权限)
SQL> grant dba to oorl_user;
SQL> grant read,write on directory dir to oorl_user;
下面开始做impdp导入:
1).在导入前因将要导入的表中有统计信息,会报ORA-39154的错,故在将imp_full_database的权限授予要导入表的用户:
SQL> grant imp_full_database to oorl_user;
2) impdp命令:
oracle@admin ~]$ impdp oorl_user/123 directory=dir dumpfile=test.dmp logfile=imp.log p.log remap_tablespace=table_test:test remap_schema=orcl_user:oorl_user
Import: Release 11.2.0.4.0 - Production on Wed Dec 18 08:10:40 2019
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
Master table "OORL_USER"."SYS_IMPORT_FULL_01" successfully loaded/unloaded
Starting "OORL_USER"."SYS_IMPORT_FULL_01": oorl_user/******** directory=dir dumpfile=test.dmp logfile=imp.log remap_tablespace=table_test:test remap_schema=orcl_user:oorl_user
Processing object type TABLE_EXPORT/TABLE/TABLE
Processing object type TABLE_EXPORT/TABLE/TABLE_DATA
. . imported "OORL_USER"."ORCL_TABLE" 14.46 KB 33 rows
Job "OORL_USER"."SYS_IMPORT_FULL_01" successfully completed at Wed Dec 18 08:10:42 2019 elapsed 0 00:00:01
到此导入成功
3.验证是否将orcl中的表导入了oorl中:
在orcl中
SQL> select count(*) from orcl_user.orcl_table;
COUNT(*)
----------
33
在oorl中:
SQL> select count(*) from oorl_user.orcl_table;
COUNT(*)
----------
33
验证成功
3.实验中出现的错误
当出现ORA—39154错时,要给用户赋予imp_full_database 的权限(有统计信息时)
grant imp_full_database to test;
Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
Master table "TEST"."SYS_IMPORT_FULL_01" successfully loaded/unloaded
Starting "TEST"."SYS_IMPORT_FULL_01": test/******** directory=dir dumpfile=t1.dmp logfile=test.log remap_tablespace=table_test:test remap_schema=user2:test
Processing object type TABLE_EXPORT/TABLE/TABLE
Processing object type TABLE_EXPORT/TABLE/TABLE_DATA
. . imported "TEST"."T1" 8.457 MB 87170 rows
Job "TEST"."SYS_IMPORT_FULL_01" successfully completed at Wed Dec 18 07:05:56 2019 elapsed 0 00:00:01
Oracle 表的导入与导出的更多相关文章
- Oracle 数据的导入和导出(SID service.msc)
一:版本号说明: (1)(Oracle11 32位系统)Oracle - OraDb11g_home1: (2)成功安装后显演示样例如以下:第一个图是管理工具.创建连接.创建表:第二个是数据库创建工 ...
- Oracle数据库的导入和导出
Oracle数据库的导入和导出,是一项重要的的技术活,不但解决了数据库的导入导出,更方便快捷的获得数据. 使用imp和exp导入导出数据 使用exp导出数据 存放目录为\ORACLE_HOME\BIN ...
- Oracle 文件的导入与导出
说明:本机使用的是32位oracle,使用的方法是plsql导入与导出 1.导出数据步骤. 1)登陆上plsql后在工具里选择导出用户对象,选择上所有的表在选择保存的路径.点击导出就可以了. 2)上边 ...
- ORACLE数据库的导入及导出
今天在客户这里导入oracle数据库,第一次导入oracle数据库,在这里记录一下,以后备用. 一.使用PLSQL导出导入ORACLE数据库: 1.打开plsql-->工具---->导出用 ...
- 关于Linux下使用expdp和impdp命令对Oracle数据库进行导入和导出操作
说明:本次导入和导出采用expdp和impdp命令进行操作,这2个命令均需要在服务器端进行操作 http://www.cnblogs.com/huacw/p/3888807.html 一. 从O ...
- Oracle数据的导入与导出
本文针对window操作系统与oracle12C的版本. 1.sqlplus执行单个sql文件 1.执行sqlplus登陆命令:sqlplus username/password@host:port/ ...
- Oracle数据库的导入与导出
导出 在命令行输入"exp",回车即可访问指定的数据库, 我这里需要访问远程的数据库,所以带上了IP.端口等一些参数,具体的参数详情可以输入"exp -help" ...
- oracle表结构和数据导出时的一些勾选项说明
使用pl/sql developer导出oracle数据库的表结构和表数据时,有一些勾选项供用户选择,需要用户根据实际情况进行勾选或取消. 导出方法如下:一.只导出表结构1.使用pl/sql deve ...
- Oracle 数据库的导入与导出
1.导入 打开cmd,用管理员登录:sqlplussys as sysdba密码不用输: 创建表空间:create tablespace tablespaceName datafile 'E:\tab ...
随机推荐
- 为什么深度(Ubuntu)Linux挂载NTFS分区只读不可写?
如前所述,经扩展,Dell Vostro 1520笔记本电脑拥有了两块硬盘. 本着旧物利用的心思,在其中一块256GiB固态盘上安装了深度linux,同时挂载另一块2TiB机械盘作为存储盘. 这块 ...
- margin:auto你真的理解么
含义 margin:auto是具有强烈计算意味的关键字,用来计算元素对应方向应该获得的剩余空间大小 填充规则 (1) 如果一侧定值,一侧auto,则auto为剩余空间大小 (2) 如果两侧均是auto ...
- [Luogu] 外星密码
https://www.luogu.org/problemnew/show/P1928 沙比提 读清题目 #include <bits/stdc++.h> using namespace ...
- [Luogu] 送花
https://www.luogu.org/problemnew/show/2073 自己yy,明显错 #include <bits/stdc++.h> using namespace s ...
- Codeforces Round #525 (Div. 2)题解
Codeforces Round #525 (Div. 2)题解 题解 CF1088A [Ehab and another construction problem] 依据题意枚举即可 # inclu ...
- Java 【打印俄文的英文字母】
俄文的的字符可以用 'A' 到 'Я '. public class main { public static void main(String args[]) { char S = 'А', C = ...
- 简述with原理
with open('x') as f: for line in f: print(line.replace('a', 'b')) 不管在处理文件过程中是否发生异常,都能保证 with 语句执行完毕后 ...
- Codeforces Round #566 (Div. 2)题解
时间\(9.05\)好评 A Filling Shapes 宽度为\(3\),不能横向填 考虑纵向填,长度为\(2\)为一块,填法有两种 如果长度为奇数则显然无解,否则\(2^{n/2}\) B Pl ...
- Hadoop hadoop的介绍和几种模式
Hadoop简介 Hadoop软件库是一个开源框架,允许使用简单的编程模型跨计算机集群分布式处理大型数据集.它旨在从单个服务器扩展到数千台计算机,每台计算机都提供本地计算和存储.库本身不是依靠硬件来提 ...
- (转)awk 详解
出处:https://blog.51cto.com/yijiu/1358416 awk详解 awk是一款非常牛逼的报告生成工具,能够将文本格式化成显示为比较直观的结果 废话不多说,直接上例子 awk的 ...