Oracle导库那些事儿

14年10月份到电子所部署系统时,用exp、imp导库命令成功的实现了Oracle数据库的导出、导入,对此,还专门发表过一篇文章Oracle数据库导出导入,讲解导出、导入过程。

昨天再对服务器新安装的Oracle数据库用exp、imp导库,一直报“EXP-0006:出现内部不一致的错误”,于是在网上百度,尝试其他导库方式,发现采用expdp、impdp数据泵同样可以完成数据库的导出、导入,而且数据泵与传统导出导入有如下区别:

1.EXP和IMP是客户段工具程序, EXPDP和IMPDP是服务端的工具程序;

2.EXP和IMP效率比较低. EXPDP和IMPDP效率高;

3.数据泵功能强大并行、过滤、转换、压缩、加密、交互等等;

4.数据泵不支持9i以前版本, EXP/IMP短期内还是比较适用;

5.同exp/imp数据泵导出包括导出表,导出方案,导出表空间,导出数据库4种方式。

有了理论支持,下面开始实战。

expdp导出Oracle数据库

   1.在sqlplus下创建Directory,优点在于让我们可以在Oracle数据库中灵活的对文件进行读写操作,极大的提高了Oracle的易用性和可扩展性。

命令:createdirectory oracleDB as ‘D:\OracleDB‘;

2.把读写权限授予特定用户

命令:Grantread,write on directory oracleDB to radpcs;

3.在dos窗口执行expdp导出命令

命令:expdp radpcs/[email protected] directory=oracleDB dumpfile =20150226.dmp logfile=20150226.logFULL=y;

到此导出工作完成,下面讲解如何用impdp导入Oracle数据库。

   impdp导入Oracle数据库

1.以sysdba级别登录Oracle数据库

命令:--sqlplus /nolog

--conn system/[email protected] as sysdba

2.创建数据表空间

命令:

--创建数据表空间

CREATE TABLESPACE RADPCS_DATA

LOGGING

DATAFILE ‘D:\OracleDB\radpcs_DATA.DBF‘ SIZE 200M REUSE AUTOEXTEND

ON NEXT 10M MAXSIZE  16383M EXTENT MANAGEMENT LOCAL UNIFORM

SIZE 1024K;

--创建索引表空间

CREATE TABLESPACE RADPCS_INDX

LOGGING

DATAFILE ‘D:\OracleDB\radpcs_INDX.DBF‘ SIZE 200M REUSE AUTOEXTEND

ON NEXT 10M MAXSIZE  16383M EXTENT MANAGEMENT LOCAL UNIFORM

SIZE 1024K;

这步很关键,创建的表空间需要和原Oracle表空间名称、个数相同,否则会导入失败。如果不知道原表空间名称、个数,就先创建一个临时的表空间进行导入,导入过程中根据错误提示,比如“RADPCS1_DATA表空间不存在”提示,缺哪个创建哪个。

3.创建用户、对用户授权

--创建用户
create user radpcs identified by ictradpcs
default tablespace radpcs_data
quota unlimited on radpcs_data
quota unlimited on radpcs_indx;

--授权
grant aq_administrator_role to radpcs;
grant aq_user_role to radpcs;
grant authenticateduser to radpcs;
grant connect to radpcs;
grant ctxapp to radpcs;
grant dba to radpcs;
grant delete_catalog_role to radpcs;
grant ejbclient to radpcs;
grant execute_catalog_role to radpcs;
grant exp_full_database to radpcs;
grant gather_system_statistics to radpcs;
grant hs_admin_role to radpcs;
grant imp_full_database to radpcs;
grant javadebugpriv to radpcs;
grant javaidpriv to radpcs;
grant javasyspriv to radpcs;
grant javauserpriv to radpcs;
grant java_admin to radpcs;
grant java_deploy to radpcs;
grant logstdby_administrator to radpcs;
grant oem_monitor to radpcs;
grant olap_dba to radpcs;
grant recovery_catalog_owner to radpcs;
grant resource to radpcs;
grant select_catalog_role to radpcs;
grant xdbadmin to radpcs;
-- Grant/Revoke system privileges
grant administer database trigger to radpcs;
grant alter any cluster to radpcs;
grant alter any dimension to radpcs;
grant alter any index to radpcs;
grant alter any indextype to radpcs;
grant alter any library to radpcs;
grant alter any outline to radpcs;
grant alter any procedure to radpcs;
grant alter any role to radpcs;
grant alter any sequence to radpcs;
grant alter any snapshot to radpcs;
grant alter any table to radpcs;
grant alter any trigger to radpcs;
grant alter any type to radpcs;
grant alter database to radpcs;
grant alter profile to radpcs;
grant alter resource cost to radpcs;
grant alter rollback segment to radpcs;
grant alter session to radpcs;
grant alter system to radpcs;
grant alter tablespace to radpcs;
grant alter user to radpcs;
grant analyze any to radpcs;
grant audit any to radpcs;
grant audit system to radpcs;
grant backup any table to radpcs;
grant become user to radpcs;
grant comment any table to radpcs;
grant create any cluster to radpcs;
grant create any context to radpcs;
grant create any dimension to radpcs;
grant create any directory to radpcs;
grant create any index to radpcs;
grant create any indextype to radpcs;
grant create any library to radpcs;
grant create any operator to radpcs;
grant create any outline to radpcs;
grant create any procedure to radpcs;
grant create any sequence to radpcs;
grant create any snapshot to radpcs;
grant create any synonym to radpcs;
grant create any table to radpcs;
grant create any trigger to radpcs;
grant create any type to radpcs;
grant create any view to radpcs;
grant create cluster to radpcs;
grant create database link to radpcs;
grant create dimension to radpcs;
grant create indextype to radpcs;
grant create library to radpcs;
grant create operator to radpcs;
grant create procedure to radpcs;
grant create profile to radpcs;
grant create public database link to radpcs;
grant create public synonym to radpcs;
grant create role to radpcs;
grant create rollback segment to radpcs;
grant create sequence to radpcs;
grant create session to radpcs;
grant create snapshot to radpcs;
grant create synonym to radpcs;
grant create table to radpcs;
grant create tablespace to radpcs;
grant create trigger to radpcs;
grant create type to radpcs;
grant create user to radpcs;
grant create view to radpcs;
grant debug any procedure to radpcs;
grant debug connect session to radpcs;
grant delete any table to radpcs;
grant drop any cluster to radpcs;
grant drop any context to radpcs;
grant drop any dimension to radpcs;
grant drop any directory to radpcs;
grant drop any index to radpcs;
grant drop any indextype to radpcs;
grant drop any library to radpcs;
grant drop any operator to radpcs;
grant drop any outline to radpcs;
grant drop any procedure to radpcs;
grant drop any role to radpcs;
grant drop any sequence to radpcs;
grant drop any snapshot to radpcs;
grant drop any synonym to radpcs;
grant drop any table to radpcs;
grant drop any trigger to radpcs;
grant drop any type to radpcs;
grant drop any view to radpcs;
grant drop profile to radpcs;
grant drop public database link to radpcs;
grant drop public synonym to radpcs;
grant drop rollback segment to radpcs;
grant drop tablespace to radpcs;
grant drop user to radpcs;
grant execute any indextype to radpcs;
grant execute any library to radpcs;
grant execute any operator to radpcs;
grant execute any procedure to radpcs;
grant execute any type to radpcs;
grant flashback any table to radpcs;
grant force any transaction to radpcs;
grant force transaction to radpcs;
grant global query rewrite to radpcs;
grant grant any object privilege to radpcs;
grant grant any privilege to radpcs;
grant grant any role to radpcs;
grant insert any table to radpcs;
grant lock any table to radpcs;
grant manage tablespace to radpcs;
grant on commit refresh to radpcs;
grant query rewrite to radpcs;
grant restricted session to radpcs;
grant resumable to radpcs;
grant select any sequence to radpcs;
grant select any table to radpcs;
grant under any table to radpcs;
grant under any type to radpcs;
grant under any view to radpcs;
grant unlimited tablespace to radpcs;
grant update any table to radpcs;
grant select on dba_free_space to radpcs;
grant select on dba_data_files to radpcs;

4.在sqlplus下创建Directory

命令:createdirectory oracleDB as ‘D:\OracleDB‘;

5.把读写权限授予特定用户

命令:Grantread,write on directory oracleDB to radpcs;

6.在dos窗口执行impdp导入命令

命令:impdp radpcs/[email protected] directory=oracleDB dumpfile=20150226.dmp logfile=20150226.log;

漫长的等待后,dos窗口会提示导出完成。如果导入过程出错,会提示错误信息(只要数据完整,一些错误可以忽略)。

参考文章:http://blog.csdn.net/indexman/article/details/7849401

时间: 2024-08-04 03:06:25

Oracle导库那些事儿的相关文章

Oracle导库,修改数据库文件

前一阵子,做oracle数据库的还原.因为是菜鸟,没用过oracle数据库.所以好多地方都不知道如何下手. 在sql server 中数据库的还原,无非就是附加数据库 .或者使用脚本来还原. 但是在oracle中数据库的还原,就没有这些可视化的工具了(自己装的客户端不算).在安装oracle服务端之后,数据库的还原必须使用dos命令行操作. oracle不懂,公司没网.然后就仅凭手机的那一丢丢流量,学习如何导库. -- 经过不懈努力,终于可以导入了. 可以导入了,但还没导入完.接下来,就出现以下

oracle导库

cmd窗口直接输入导库命令即可,不需要进入sqlplus C:\Documents and Settings\Administrator> imp username/[email protected] file=E:\**.dmp full=y 在导库之前请新建用户或者清空所有对象:包括表对象,函数,触发器,存储过程.

Oracle导库及相关操作

SELECT * FROM dba_profiles s WHERE s.profile='DEFAULT' AND resource_name='PASSWORD_LIFE_TIME';--如果后面显示180天的请将密码有效期由默认的180天修改成“无限制”:ALTER PROFILE DEFAULT LIMIT PASSWORD_LIFE_TIME UNLIMITED;alter user system identified by dreamsoft;select * from dba_di

SqlServer导库语句

1 GO 2 /****** 对象: StoredProcedure [dbo].[sp_ExportDatabase] 脚本日期: 07/18/2013 12:37:26 ******/ 3 SET ANSI_NULLS ON 4 GO 5 SET QUOTED_IDENTIFIER ON 6 GO 7 ----该存储过程建立在新帐套中,并在新账套中执行 8 9 if Exists(select * from sysobjects where name=N'sp_ExportDatabase'

尝试加载 Oracle 客户端库时引发 BadImageFormatException。如果在安装 32 位 Oracle 客户端组件的情况下以 64 位模式运行,将出现此问题。

从10G开始,Oracle提供了一个较为轻量级的客户包,叫做Instant Client. 将它安装好后,就不用再安装庞大的Oracle Client了. 这样一来,只要客户端下载Instant Client,直接解压,设置Path就ok了.具体设置如下:1.下载32位Oracle InstantClient 2.将Oracle InstantClient解压到某目录 3.打开PL/SQL,在perference里面设置OCI Library和Oracle_home,例子如下:        

Oracle 跨库 查询 复制表数据

在目前绝大部分数据库有分布式查询的需要.下面简单的介绍如何在oracle中配置实现跨库访问. 比如现在有2个数据库服务器,安装了2个数据库.数据库server A和B.现在来实现在A库中访问B的数据库. 第一步.配置A服务器端的tnsnames.ora文件(TNSNAMES.ORA Network Configuration File),该文件存放的位置为: $ORACLE_HOME/network/admin/tnsnames.ora 需要在该文件中增加对B库的配置项,格式如下 ZBCDB3

尝试加载 Oracle 客户端库时引发 BadImageFormatException。问题记录

1公司电脑是win7 64位旗舰版,刚来时配的新电脑,4G+i5这个配置不装64位那算是浪费了.谁知道一切装完毕后,打开项目却连不上oracle数据了... 首先是pl/sql连不上,我在本地装了个oracle 11g r2 64位的.装了oracle服务器,应该是不用再装客户端,pl/sql应该就能连上的,应为oracle服务器版本自带了客户端的那些管理工具和功能.但是pl/sql一直报个错啊!大概意思是说找不到32位的oci.dll文件之类的错误,网上一搜,说pl/sql装在64位系统上,要

ORACLE 建库过程总结

1,忘记sys密码 打开CMD命令窗口,执行以下操作: 1,SQLPLUS /NOLOG; 2, 3,CONNECT / AS SYSDBA 4, 5,ALTER USER SYS IDENTIFIED BY 新密码 6, 7,ALTER USER SYSTEM IDENTIFIED BY 新密码 8, 2,以sys账号登陆 建立用户表空间,索引表空间,创建用户,授权,分配配额: --创建用户表空间--基础区 CREATE TABLESPACE TABLESPACE_NAME DATAFILE

webservice 尝试加载 Oracle 客户端库时引发 BadImageFormatException。如果在安装 32 位 Oracle 客户端组件的情况下运行,将出现此问题

最近做的项目中,应用服务器迁移到另外一台服务器,操作系统升级为win10,配置好IIS里的应用程序发布网站和Webservice网站后, 客户端程序调用Webservice出错: “尝试加载 Oracle 客户端库时引发 BadImageFormatException.如果在安装 32 位 Oracle 客户端组件的情况下运行,将出现此问题”. 写了个控制台程序,在本机上运行测试,还是出现这个问题: 最开始以为是oracle客户端的问题,重新安装另外一个版本的客户端,运行程序还是出现这个错误.