OGG不同表指定不同extract、dump、replicat

本文详细介绍了如何在Oracle环境中配置 Extract、DUMP和Replicat进程,包括创建表空间、配置对象抽取、同步表和视图,以及添加补充日志和迁移过程。涉及对象选择、表空间管理、DDL复制和数据迁移等关键步骤。

注意:每个extract对应一个dump和replicat,有多个个extract就有多少个dump和replicat

1.1 环境准备

create tablespace test_tbs datafile '/u01/app/oracle/oradata/ggg11g/test_tbs01.dbf' size 10M autoextend on maxsize unlimited;
create user test identified by test account unlock default tablespace test_tbs;
grant  unlimited tablespace to test;
grant connect,resource to test;
grant select any dictionary to test;
grant select any table to test;
grant create view to test;

-- 创建相关测试对象
conn test/test;
create table t1 as select * from scott.emp;
create table t2 as select * from scott.dept;
create table t3 as select * from dba_objects;
create table t4 as select * from dba_users;
create index idx_t1_sal on t1(sal);
create or replace view v_sel_t1_empno_ename_sal as select empno,ename,sal from t1;

-- 查询test下的对象

col object_name for a25;
select object_name,object_type from dba_objects where owner = upper('test');

OBJECT_NAME               OBJECT_TYPE
------------------------- -------------------
T1                        TABLE
T2                        TABLE
T3                        TABLE
IDX_T1_SAL                INDEX
V_SEL_T1_EMPNO_ENAME_SAL  VIEW
T4                        TABLE

1.2 目标端创建需要被同步的对象的表空间

-- 查看test用户下对象关联的表空间,需要手动在目标端创建
col tablespace_name for a30;
select distinct owner,
       tablespace_name
from   dba_segments
where  owner in (select username
                 from   dba_users 
                 where  username = 'TEST'
                 and    account_status = 'OPEN');


OWNER      TABLESPACE_NAME
---------- ------------------------------
TEST       TEST_TBS


-- 查看对应表空间的大小

set line 121;
set pagesize 49999;
col tablespace_name format a25; 
col used_percent format a12;
col used_gb format 99999;
col size_gb format 99999;
select a.tablespace_name,
       round(a.tablespace_size * b.value / 1024 / 1024 / 1024, 2) TOTAL_GB,
       round(a.used_space * b.value / 1024 / 1024 / 1024, 2) USED_GB,
       round(a.tablespace_size * b.value / 1024 / 1024 / 1024, 2) -
       round(a.used_space * b.value / 1024 / 1024 / 1024, 2) FREE_GB,
       ROUND(A.used_percent, 2)|| '%' used_percent
 from  dba_tablespace_usage_metrics a, v$parameter b
 where b.NAME = 'db_block_size'
and    a.tablespace_name in (select distinct tablespace_name
                             from   dba_segments
                             where  owner in (select username
                                              from   dba_users 
                                              where  username = 'TEST'
                                              and    account_status = 'OPEN'))
 order by used_percent DESC;

TABLESPACE_NAME             TOTAL_GB USED_GB    FRE
<think>我们正在处理用户关于Oracleexpdp导出指定数据的问题。根据引用内容,用户意图是使用expdp工具将特定的数据导出到dump文件。我们将结合引用信息,给出详细步骤示例。关键点:1.使用expdp命令导出指定。2.需要指定目录对象(directory)、转储文件(dumpfile)、日志文件(logfile)要导出的(tables)。3.注意权限目录对象的创建。步骤:1.创建目录对象(如果不存在)并授予权限。2.使用expdp命令导出指定。参考引用[1][2]的示例:expdpstudent/123456@orcl dumpfile=student.dmplogfile=student.log tables=stuinfo directory=dir另外,引用[4]展示了导出分区的分区,引用[5]展示了导入时的重映射,但用户当前需求是导出指定。详细说明:1.目录对象(directory)是Oracle中指向操作系统目录的数据库对象,用于读写转储文件。2.需要确保用户有读写该目录对象的权限。示例步骤:步骤1:创建目录对象(以sysdba身份登录操作) ```sql--创建目录对象CREATEOR REPLACEDIRECTORYdir AS'/home/oracle/dumps'; --授予用户对该目录的读写权限GRANT READ, WRITE ONDIRECTORYdir TOstudent;```步骤2:使用expdp导出数据在操作系统命令行中执行(注意:expdp是外部工具,需要在Oracle服务器上执行): ```bashexpdpstudent/123456@orcl dumpfile=student.dmp logfile=student.logtables=stuinfodirectory=dir```说明:- `student/123456@orcl`:用户名/密码@数据库服务名(或SID) -`dumpfile`:指定转储文件名- `logfile`:指定日志文件名-`tables`:指定要导出的,可以指定多个,用逗号分隔,如:`tables=table1,table2` -`directory`:指定之前创建的目录对象名如果需要导出多个,可以这样写: ```bashexpdpstudent/123456@orcl dumpfile=student.dmp logfile=student.logtables=stuinfo,stu_scoredirectory=dir```注意事项:1.执行expdp命令的用户需要具有EXP_FULL_DATABASE角色(或至少对要导出的有导出权限)。2.目录对象指向的操作系统目录必须存在,且Oracle软件用户(如oracle)必须有读写权限。3.如果名包含特殊字符或大小写敏感,需要用双引号括起来,如:`tables="\"MyTable\""`(在Linux下可能需要转义)。引用[3][4]提供了更复杂的示例,比如按条件导出或导出分区,但用户当前需求是指定导出。如果用户需要按条件导出(例如只导出部分数据),可以使用`query`参数,例如:```bashexpdp student/123456@orcldumpfile=student.dmplogfile=student.log tables=stuinfo directory=dirquery='stuinfo:"WHEREage>20"' ```但注意,query参数的使用语法可能因版本平台略有不同,且条件复杂时要注意转义。最后,根据用户需求,我们生成相关问题。注意:我们引用了多个引用,但用户提供的引用都是关于expdp导出数据的,所以我们在回答中引用了这些示例。</think>### Oracle expdp 导出指定dump 文件 使用 Oracle 数据泵工具 `expdp` 导出指定dump 文件的步骤如下: #### 1. **创建目录对象(Directory)** 首先在数据库中创建指向物理路径的目录对象: ```sql CREATE OR REPLACE DIRECTORY exp_dir AS '/u01/app/oracle/dumps'; GRANT READ, WRITE ON DIRECTORY exp_dir TO your_user; ``` - `/u01/app/oracle/dumps` 是服务器上的物理路径 - `your_user` 是执行导出的用户 #### 2. **执行 expdp 命令** 通过命令行执行导出操作: ```bash expdp your_user/your_password@your_db DIRECTORY=exp_dir DUMPFILE=table_export.dmp LOGFILE=export.log TABLES=your_schema.table1,your_schema.table2 ``` #### 关键参数说明: | 参数 | 说明 | 示例 | |------|------|------| | `DIRECTORY` | 预先创建的目录对象名 | `DIRECTORY=exp_dir` | | `DUMPFILE` | 生成的 dump 文件名 | `DUMPFILE=data_export.dmp` | | `LOGFILE` | 日志文件名 | `LOGFILE=export.log` | | `TABLES` | 要导出的名(支持多) | `TABLES=hr.employees,sales.orders` | | `SCHEMAS` | 导出整个方案(可选) | `SCHEMAS=hr` | | `COMPRESSION` | 启用压缩(可选) | `COMPRESSION=ALL` | #### 3. **验证导出结果** 检查日志文件确认导出状态: ```bash cat /u01/app/oracle/dumps/export.log ``` 成功时会显示: ``` Job "YOUR_USER"."SYS_EXPORT_TABLE_01" completed ``` #### 注意事项: 1. **权限要求**:用户需有 `EXP_FULL_DATABASE` 角色或的 `SELECT` 权限 2. **名规范**:名区分大小写时需用双引号:`TABLES="\"MyTable\""` 3. **分区导出**:可指定分区(引用[4]): ```bash TABLES=OLS.LOAN_UN_APP_INFO_CLOB:SYS_P14082 ``` 4. **网络导出**:支持远程导出(引用[3]): ```bash expdp user/pwd@192.168.1.100/orclpdb1 ... ``` #### 完整示例: ```bash expdp hr/hr123@orclpdb DIRECTORY=data_pump DUMPFILE=hr_emp.dmp LOGFILE=hr_export.log TABLES=employees,departments COMPRESSION=ALL ``` > **重要提示**: > - 确保服务器目录有写入权限 > - 生产环境建议添加 `EXCLUDE=STATISTICS` 跳过统计信息(引用[4]) > - 大导出可使用 `PARALLEL=4` 加速 [^1]: Oracle expdp导出数据:expdpstudent/123456@orcldumpfile=student.dmplogfile=student.logtables=stuinfodirectory=dir [^2]: expdp导出指定:expdp student/123456@orcl dumpfile=student.dmp logfile=student.log tables=stuinfo directory=dir [^4]: 分区导出示例:tables=OLS.LOAN_UN_APP_INFO_CLOB:SYS_P14082
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值