Oracle数据泵的使用
http://hi.baidu.com/hanbingxiaoshi/item/63724f51aad754968c12edae 1、连接Oracle数据库 SQL conn / as sysdba 已连接。 2、创建一个操作目录 SQL create directory dump_dir as 'e:\dump'; 注意同时需要使用操作系统命令在硬盘上创建这个物理目录。 目录
http://hi.baidu.com/hanbingxiaoshi/item/63724f51aad754968c12edae
1、连接Oracle数据库
SQL> conn / as sysdba
已连接。
2、创建一个操作目录
SQL> create directory dump_dir as 'e:\dump';
注意同时需要使用操作系统命令在硬盘上创建这个物理目录。
目录已创建。
3、使用以下命令创建一个导出文件目录
SQL> grant read,write on directory dump_dir to scott;
授权成功。
4、使用命令expdp导出数据
C:\>expdp scott/tiger directory=dump_dir dumpfile=20080601.dmp tables=dept,emp
Export: Release 10.2.0.1.0 - Production on 星期三, 18 6月, 2008 15:49:00
Copyright (c) 2003, 2005, Oracle. All rights reserved.
连接到: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
启动 "SCOTT"."SYS_EXPORT_TABLE_01": scott/******** directory=dump_dir dumpfile=20080601.dmp table
dept,emp
正在使用 BLOCKS 方法进行估计...
处理对象类型 TABLE_EXPORT/TABLE/TABLE_DATA
使用 BLOCKS 方法的总估计: 128 KB
处理对象类型 TABLE_EXPORT/TABLE/TABLE
处理对象类型 TABLE_EXPORT/TABLE/INDEX/INDEX
处理对象类型 TABLE_EXPORT/TABLE/CONSTRAINT/CONSTRAINT
处理对象类型 TABLE_EXPORT/TABLE/CONSTRAINT/REF_CONSTRAINT
. . 导出了 "SCOTT"."DEPT" 5.656 KB 4 行
. . 导出了 "SCOTT"."EMP" 7.820 KB 14 行
已成功加载/卸载了主表 "SCOTT"."SYS_EXPORT_TABLE_01"
******************************************************************************
SCOTT.SYS_EXPORT_TABLE_01 的转储文件集为:
E:\DUMP\20080601.DMP
作业 "SCOTT"."SYS_EXPORT_TABLE_01" 已于 15:49:22 成功完成
C:\>
**************************************************************************************************************
常见错误
如果没有在指定的硬盘上建立物理文件 ,则会出现如下错误提示信息:
解决的方法是现在硬盘上创建指定的物理文件目录,然后在执行expdp程序。
Oracle 中的 create directory dump_dir as 'e:\dump';
命令只是在逻辑上创建了一个Oracle能够识别的目录和硬盘上的一个物理目录之间的联系,
并不能真正的在硬盘上创建物理目录。
**************************************************************************************************************
C:\>expdp scott/tiger directory=dump_dir dumpfile=20080601.dmp tables=dept,emp
Export: Release 10.2.0.1.0 - Production on 星期三, 18 6月, 2008 15:46:19
Copyright (c) 2003, 2005, Oracle. All rights reserved.
连接到: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
ORA-39002: 操作无效
ORA-39070: 无法打开日志文件。
ORA-29283: 文件操作无效
ORA-06512: 在 "SYS.UTL_FILE", line 475
ORA-29283: 文件操作无效
导入命令:
impdp scott/tiger directory=dump_dir dumpfile=20080601.dmp tables=dept,emp
C:\>impdp scott/tiger directory=dump_dir dumpfile=20080601.dmp tables=dept,emp
Import: Release 10.2.0.1.0 - Production on 星期三, 18 6月, 2008 15:56:11
Copyright (c) 2003, 2005, Oracle. All rights reserved.
连接到: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
已成功加载/卸载了主表 "SCOTT"."SYS_IMPORT_TABLE_01"
启动 "SCOTT"."SYS_IMPORT_TABLE_01": scott/******** directory=dump_dir dumpfile=20080601.dmp table
dept,emp
处理对象类型 TABLE_EXPORT/TABLE/TABLE
处理对象类型 TABLE_EXPORT/TABLE/TABLE_DATA
. . 导入了 "SCOTT"."DEPT" 5.656 KB 4 行
. . 导入了 "SCOTT"."EMP" 7.820 KB 14 行
处理对象类型 TABLE_EXPORT/TABLE/INDEX/INDEX
处理对象类型 TABLE_EXPORT/TABLE/CONSTRAINT/CONSTRAINT
处理对象类型 TABLE_EXPORT/TABLE/CONSTRAINT/REF_CONSTRAINT
作业 "SCOTT"."SYS_IMPORT_TABLE_01" 已于 15:56:20 成功完成
C:\>
查看结果,发现删除的数据表又已经找回来了:
SQL> set linesize 150;
SQL> select * from scott.emp;
EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
---------- ---------- --------- ---------- -------------- ---------- ---------- ----------
7369 SMITH CLERK 7902 17-12月-80 800 20
7499 ALLEN SALESMAN 7698 20-2月 -81 1600 300 30
7521 WARD SALESMAN 7698 22-2月 -81 1250 500 30
7566 JONES MANAGER 7839 02-4月 -81 2975 20
7654 MARTIN SALESMAN 7698 28-9月 -81 1250 1400 30
7698 BLAKE MANAGER 7839 01-5月 -81 2850 30
7782 CLARK MANAGER 7839 09-6月 -81 2450 10
7788 SCOTT ANALYST 7566 19-4月 -87 3000 20
7839 KING PRESIDENT 17-11月-81 5000 10
7844 TURNER SALESMAN 7698 08-9月 -81 1500 0 30
7876 ADAMS CLERK 7788 23-5月 -87 1100 20
EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
---------- ---------- --------- ---------- -------------- ---------- ---------- ----------
7900 JAMES CLERK 7698 03-12月-81 950 30
7902 FORD ANALYST 7566 03-12月-81 3000 20
7934 MILLER CLERK 7782 23-1月 -82 1300 10
已选择14行。
SQL> select * from scott.dept;
DEPTNO DNAME LOC
---------- -------------- -------------
10 ACCOUNTING NEW YORK
20 RESEARCH DALLAS
30 SALES CHICAGO
40 OPERATIONS BOSTON
SQL>
*******************************************************************************************************************************************
对Oracle10g中的数据泵导出数据的分析
*******************************************************************************************************************************************
Oracle10g中的数据泵只能用于服务器端,而不能用于客户端,它可以导出表、方案、表空间和整个数据库。
1、导出表
C:\>expdp scott/tiger directory=dump_dir dumpfile=20080601.dmp tables=dept,emp
2、导出方案
导出方案将方案的所有数据库对象和数据库表导出到一个文件中。
C:\>expdp hr/hr directory=dump_dir dumpfile=20080601schema.dmp schemas=hr
C:\>expdp hr/hr directory=dump_dir dumpfile=20080601schema.dmp schemas=hr
Export: Release 10.2.0.1.0 - Production on 星期三, 18 6月, 2008 16:04:16
Copyright (c) 2003, 2005, Oracle. All rights reserved.
连接到: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
启动 "HR"."SYS_EXPORT_SCHEMA_01": hr/******** directory=dump_dir dumpfile=20080601schema.dmp sche
s=hr
正在使用 BLOCKS 方法进行估计...
处理对象类型 SCHEMA_EXPORT/TABLE/TABLE_DATA
使用 BLOCKS 方法的总估计: 448 KB
处理对象类型 SCHEMA_EXPORT/PRE_SCHEMA/PROCACT_SCHEMA
处理对象类型 SCHEMA_EXPORT/SEQUENCE/SEQUENCE
处理对象类型 SCHEMA_EXPORT/TABLE/TABLE
处理对象类型 SCHEMA_EXPORT/TABLE/GRANT/OWNER_GRANT/OBJECT_GRANT
处理对象类型 SCHEMA_EXPORT/TABLE/INDEX/INDEX
处理对象类型 SCHEMA_EXPORT/TABLE/CONSTRAINT/CONSTRAINT
处理对象类型 SCHEMA_EXPORT/TABLE/INDEX/STATISTICS/INDEX_STATISTICS
处理对象类型 SCHEMA_EXPORT/TABLE/COMMENT
处理对象类型 SCHEMA_EXPORT/PROCEDURE/PROCEDURE
处理对象类型 SCHEMA_EXPORT/PROCEDURE/ALTER_PROCEDURE
处理对象类型 SCHEMA_EXPORT/VIEW/VIEW
处理对象类型 SCHEMA_EXPORT/TABLE/CONSTRAINT/REF_CONSTRAINT
处理对象类型 SCHEMA_EXPORT/TABLE/TRIGGER
处理对象类型 SCHEMA_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS
. . 导出了 "HR"."COUNTRIES" 6.085 KB 25 行
. . 导出了 "HR"."DEPARTMENTS" 6.632 KB 27 行
. . 导出了 "HR"."EMPLOYEES" 15.76 KB 107 行
. . 导出了 "HR"."JOBS" 6.609 KB 19 行
. . 导出了 "HR"."JOB_HISTORY" 6.585 KB 10 行
. . 导出了 "HR"."LOCATIONS" 7.710 KB 23 行
. . 导出了 "HR"."REGIONS" 5.289 KB 4 行
已成功加载/卸载了主表 "HR"."SYS_EXPORT_SCHEMA_01"
******************************************************************************
HR.SYS_EXPORT_SCHEMA_01 的转储文件集为:
E:\DUMP\20080601SCHEMA.DMP
作业 "HR"."SYS_EXPORT_SCHEMA_01" 已于 16:04:50 成功完成
C:\>
如果没有授予hr用户操作dump_dir目录的权限,则会出现如下错误提示信息:
C:\>expdp hr/hr directory=dump_dir dumpfile=20080601schema.dmp schemas=hr
Export: Release 10.2.0.1.0 - Production on 星期三, 18 6月, 2008 16:02:55
Copyright (c) 2003, 2005, Oracle. All rights reserved.
连接到: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
ORA-39002: 操作无效
ORA-39070: 无法打开日志文件。
ORA-39087: 目录名 DUMP_DIR 无效
3、导出表空间
expdp system/sysadmin directory=dump_dir dumpfile=tablespace.dmp tablespaces=users
C:\>expdp system/sysadmin directory=dump_dir dumpfile=tablespace.dmp tablespaces=users
Export: Release 10.2.0.1.0 - Production on 星期三, 18 6月, 2008 16:09:19
Copyright (c) 2003, 2005, Oracle. All rights reserved.
连接到: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
启动 "SYSTEM"."SYS_EXPORT_TABLESPACE_01": system/******** directory=dump_dir dumpfile=tablespace.
p tablespaces=users
正在使用 BLOCKS 方法进行估计...
处理对象类型 TABLE_EXPORT/TABLE/TABLE_DATA
ORA-39139: 数据泵不支持 XMLSchema 对象。将跳过 TABLE_DATA:"OE"."PURCHASEORDER"。
使用 BLOCKS 方法的总估计: 1.187 MB
处理对象类型 TABLE_EXPORT/TABLE/TABLE
处理对象类型 TABLE_EXPORT/TABLE/INDEX/INDEX
处理对象类型 TABLE_EXPORT/TABLE/CONSTRAINT/CONSTRAINT
处理对象类型 TABLE_EXPORT/TABLE/INDEX/STATISTICS/INDEX_STATISTICS
处理对象类型 TABLE_EXPORT/TABLE/RLS_POLICY
处理对象类型 TABLE_EXPORT/TABLE/CONSTRAINT/REF_CONSTRAINT
处理对象类型 TABLE_EXPORT/TABLE/TRIGGER
. . 导出了 "OE"."LINEITEM_TABLE" 283.5 KB 2232 行
. . 导出了 "OE"."ACTION_TABLE" 14.87 KB 132 行
. . 导出了 "OE"."SUBCATEGORY_REF_LIST_NESTEDTAB" 6.398 KB 21 行
. . 导出了 "OE"."PRODUCT_REF_LIST_NESTEDTAB" 12.32 KB 288 行
. . 导出了 "OE"."CATEGORIES_TAB" 13.12 KB 22 行
. . 导出了 "SCOTT"."DEPT" 5.656 KB 4 行
. . 导出了 "SCOTT"."EMP" 7.820 KB 14 行
. . 导出了 "SCOTT"."SALGRADE" 5.585 KB 5 行
. . 导出了 "SCOTT"."BONUS" 0 KB 0 行
已成功加载/卸载了主表 "SYSTEM"."SYS_EXPORT_TABLESPACE_01"
******************************************************************************
SYSTEM.SYS_EXPORT_TABLESPACE_01 的转储文件集为:
E:\DUMP\TABLESPACE.DMP
作业 "SYSTEM"."SYS_EXPORT_TABLESPACE_01" 已经完成, 但是有 1 个错误 (于 16:09:48 完成)
C:\>
4、导出整个数据库
expdp system/sysadmin directory=dump_dir dumpfile=full.dmp full=y
*******************************************************************************************************************************************
对Oracle10g中的数据泵导入数据的分析
*******************************************************************************************************************************************
1、导入表
impdp scott/tiger directory=dump_dir dumpfile=dumptab.dmp tables=dept,emp
2、导入方案
一般只能导入自己的方案,如果想导入其他方案,必须具有EXP_FULL_DATABASE或者DBA权限。
impdp scott/tiger directory=dump_dir dumpfile=dumptab.dmp schemas=scott
3、导入表空间
impdp system/sysadmin directory=dump_dir dumpfile=tablespace.dmp tablespaces=users
4、导入整个数据库
impdp system/sysadmin directory=dump_dir dumpfile=full.dmp full=y
**************************************************************************************************************************************
使用Oracle10g的数据泵可以移动表空间
**************************************************************************************************************************************
使用impdp和expdp可以实现在不同的数据库之间移动表空间。在Oracle10g以前,只能在同一个操作系统平台
之间移动表空间。在Oracle10g之后,不仅可以在同一个操作系统平台之间移动表空间,还可以在不同的操作系统
之间移动表空间。用户可以通过查看数据库视图v$transportable_platform查询到哪些操作系统平台之间可以移动
表空间,即:
SQL> col platform_name format a60;
SQL> select * from v$transportable_platform order by platform_id;
PLATFORM_ID PLATFORM_NAME ENDIAN_FORMAT
----------- ------------------------------------------------------------ --------------
1 Solaris[tm] OE (32-bit) Big
2 Solaris[tm] OE (64-bit) Big
3 HP-UX (64-bit) Big
4 HP-UX IA (64-bit) Big
5 HP Tru64 UNIX Little
6 AIX-Based Systems (64-bit) Big
7 Microsoft Windows IA (32-bit) Little
8 Microsoft Windows IA (64-bit) Little
9 IBM zSeries Based Linux Big
10 Linux IA (32-bit) Little
11 Linux IA (64-bit) Little
PLATFORM_ID PLATFORM_NAME ENDIAN_FORMAT
----------- ------------------------------------------------------------ --------------
12 Microsoft Windows 64-bit for AMD Little
13 Linux 64-bit for AMD Little
15 HP Open VMS Little
16 Apple Mac OS Big
17 Solaris Operating System (x86) Little
18 IBM Power Based Linux Big
已选择17行。
要移动表空间必须满足如下条件:
1、原数据库和目标数据库必须有相同的数据库字符集和国家字符集
2、不能移动到具有同名表空间的目标数据库中。如果出现同名,只能使用ALTER TABLESPACE RENAME
命令更改源数据库或者目标数据库的表空间名称。
3、不能移动SYSTEM或者SYS用户对象所在的表空间。
4、要将表空间在不同的操作系统之间移动,必须将初始化参数COMPATIBLE参数设置为10.0以上。
因为Oracle10g以前的版本不支持在不同操作系统之间移动表空间。
5、要移动的表空间集合必须满足自包含,可以使用DBMS_TTS的过程TRANSPORT_SET_CHECK检查
是否自包含,然后在临时表transprot_set_violations内查询检查结果。
以下是移动表空间的步骤,以移动USERS表空间为例子:
第一步:设置表空间为只读表空间:
alter tablespace users read only;
第二步:使用expdp导出表空间
expdp 用户名/口令 directory=目录名称 dumpfile=导出文件名称 transport_tablespaces=表空间名称
例如:
expdp system/sysadmin directory=dump_dir dumpfile=tablespace.dmp tablespaces=users;
第三步:使用操作系统命令将导出文件和传输表空间的数据文件复制到目标数据库中。
第四步:在目标数据库上使用IMPDP将源数据库的导出内容导入到目标数据库中,IMPDP导入表空间的
命令格式如下:
IMP 用户名称/口令 directory=目录名称 dumpfile=导出文件名称 transport_tablespaces=表空间名称
transport_datafiles=;数据文件名称'
例如:
impdp system/sysadmin directory=dump_dir dumpfile=tablespace.dmp tablespaces=users
transport_datafiles=D:\oracle\oradata\oramgr\user01.dbf;
第五步:使用一下命令将原数据库的传输表空间恢复为可读写
alter tablespace users read write;

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

The retention period of Oracle database logs depends on the log type and configuration, including: Redo logs: determined by the maximum size configured with the "LOG_ARCHIVE_DEST" parameter. Archived redo logs: Determined by the maximum size configured by the "DB_RECOVERY_FILE_DEST_SIZE" parameter. Online redo logs: not archived, lost when the database is restarted, and the retention period is consistent with the instance running time. Audit log: Configured by the "AUDIT_TRAIL" parameter, retained for 30 days by default.

The Oracle database startup sequence is: 1. Check the preconditions; 2. Start the listener; 3. Start the database instance; 4. Wait for the database to open; 5. Connect to the database; 6. Verify the database status; 7. Enable the service (if necessary ); 8. Test the connection.

To find the number of occurrences of a character in Oracle, perform the following steps: Get the total length of a string; Get the length of the substring in which a character occurs; Count the number of occurrences of a character by subtracting the substring length from the total length.

Oracle database server hardware configuration requirements: Processor: multi-core, with a main frequency of at least 2.5 GHz. For large databases, 32 cores or more are recommended. Memory: At least 8GB for small databases, 16-64GB for medium sizes, up to 512GB or more for large databases or heavy workloads. Storage: SSD or NVMe disks, RAID arrays for redundancy and performance. Network: High-speed network (10GbE or higher), dedicated network card, low-latency network. Others: Stable power supply, redundant components, compatible operating system and software, heat dissipation and cooling system.

The amount of memory required by Oracle depends on database size, activity level, and required performance level: for storing data buffers, index buffers, executing SQL statements, and managing the data dictionary cache. The exact amount is affected by database size, activity level, and required performance level. Best practices include setting the appropriate SGA size, sizing SGA components, using AMM, and monitoring memory usage.

To create a scheduled task in Oracle that executes once a day, you need to perform the following three steps: Create a job. Add a subjob to the job and set its schedule expression to "INTERVAL 1 DAY". Enable the job.

The amount of memory required for an Oracle database depends on the database size, workload type, and number of concurrent users. General recommendations: Small databases: 16-32 GB, Medium databases: 32-64 GB, Large databases: 64 GB or more. Other factors to consider include database version, memory optimization options, virtualization, and best practices (monitor memory usage, adjust allocations).

70B model, 1000 tokens can be generated in seconds, which translates into nearly 4000 characters! The researchers fine-tuned Llama3 and introduced an acceleration algorithm. Compared with the native version, the speed is 13 times faster! Not only is it fast, its performance on code rewriting tasks even surpasses GPT-4o. This achievement comes from anysphere, the team behind the popular AI programming artifact Cursor, and OpenAI also participated in the investment. You must know that on Groq, a well-known fast inference acceleration framework, the inference speed of 70BLlama3 is only more than 300 tokens per second. With the speed of Cursor, it can be said that it achieves near-instant complete code file editing. Some people call it a good guy, if you put Curs
