parallel dml enable

这篇具有很好参考价值的文章主要介绍了parallel dml enable。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

A. Export/import method

This method involves exporting the non partitioned table, creating a partitioned table, and then importing data into the new partitioned table.

1) Export your table:

$ exp <user_name>/<pwd> tables=TEST_TABLE1 file=exp.dmp

2) Drop the table:

SQL> drop table TEST_TABLE1;

3) Recreate the table with partitions:

SQL> create table TEST_TABLE1 (qty number(3), name varchar2(15)) partition by range (qty)(partition p1 values less than (501),
partition p2 values less than (maxvalue));

4) Import the table with ignore=y:

$ imp <user_name>/<pwd> file=exp.dmp ignore=y

The ignore=y causes the import to skip the table creation and continues to load all rows.

With Data Pump export/import (expdp/impdp) you can use the  table_exists_action option of impdp e.g. table_exists_action = APPEND or table_exists_action = REPLACE.

Also review Note 552424.1 Export/Import DataPump Parameter ACCESS_METHOD - How to Enforce a Method of Loading and Unloading Data ?

B. Insert with a subquery method

1) Create a partitioned table:

SQL> create table partbl (qty number(3), name varchar2(15)) partition by range (qty) (partition p1 values less than (501),partition p2 values less than (maxvalue));


2) Insert into the partitioned table with a subquery from the non-partitioned table:

SQL> insert into partbl (qty, name) select * from origtbl;


3) If you want the partitioned table to have the same name as the original table, then drop the original table and rename the new table:

SQL> drop table origtbl;
SQL> alter table partbl rename to origtbl;

You may improve the insert performance with direct path insert and utilize parallelism. Examples below show how this can be done and how it can be recognized in the execution plan.

Conventional insert

SQL> insert into partbl (qty, name) select * from origtbl;
--------------------------------------------
| Id  | Operation                | Name    |
--------------------------------------------
|   0 | INSERT STATEMENT         |         |
|   1 |  LOAD TABLE CONVENTIONAL |         |
|   2 |   TABLE ACCESS FULL      | ORIGTBL |
--------------------------------------------

Direct load insert

SQL> insert /*+APPEND*/ into partbl (qty, name) select * from origtbl;
--------------------------------------
| Id  | Operation          | Name    |
--------------------------------------
|   0 | INSERT STATEMENT   |         |
|   1 |  LOAD AS SELECT    |         |
|   2 |   TABLE ACCESS FULL| ORIGTBL |
--------------------------------------

Direct load insert with parallel query part

SQL> insert /*+APPEND PARALLEL*/ into partbl (qty, name) select * from origtbl;
------------------------------------------
| Id  | Operation             | Name     |
------------------------------------------
|   0 | INSERT STATEMENT      |          |
|   1 |  LOAD AS SELECT       |          |
|   2 |   PX COORDINATOR      |          |
|   3 |    PX SEND QC (RANDOM)| :TQ10000 |
|   4 |     PX BLOCK ITERATOR |          |
|*  5 |      TABLE ACCESS FULL| ORIGTBL  |
------------------------------------------

Note LOAD AS SELECT  is above PX COORDINATOR in the execution plan.

Direct load insert with parallel query and insert parts

SQL>alter session enable parallel dml;
SQL> insert /*+APPEND PARALLEL*/ into partbl (qty, name) select * from origtbl;
------------------------------------------
| Id  | Operation             | Name     |
------------------------------------------
|   0 | INSERT STATEMENT      |          |
|   1 |  PX COORDINATOR       |          |
|   2 |   PX SEND QC (RANDOM) | :TQ10000 |
|   3 |    LOAD AS SELECT     |          |
|   4 |     PX BLOCK ITERATOR |          |
|*  5 |      TABLE ACCESS FULL| ORIGTBL  |
------------------------------------------

Note LOAD AS SELECT  is below PX COORDINATOR in the execution plan.

An alternative to insert ... select is to use create table as select: creating the partitioned table and loading data into it in one go.
The execution plan shows direct path load with both dml and select parts parallel.

SQL>alter session enable parallel dml;
SQL> create table partbl (qty, name) partition by range (qty) (partition p1 values less than (501),partition p2 values less than (maxvalue))
  2  as select /*+PARALLEL*/ * from origtbl;
-------------------------------------------
| Id  | Operation              | Name     |
-------------------------------------------
|   0 | CREATE TABLE STATEMENT |          |
|   1 |  PX COORDINATOR        |          |
|   2 |   PX SEND QC (RANDOM)  | :TQ10000 |
|   3 |    LOAD AS SELECT      |          |
|   4 |     PX BLOCK ITERATOR  |          |
|*  5 |      TABLE ACCESS FULL | ORIGTBL  |
-------------------------------------------

C. Partition Exchange method

ALTER TABLE EXCHANGE PARTITION can be used to convert a partition (or subpartition) into a non-partitioned table and a non-partitioned table into a partition (or subpartition) of a partitioned table by exchanging their data and index segments. Unless update indexes close the ALTER TABLE ... EXCHANGE PARTITION command is a dictionary operation with no data movement. Further information about this method can be found in the Oracle documentation (e.g. 11.2) and in Note 198120.1.

The steps involved briefly are the following:

1) Create the partitioned table with the required partitions
2) Have the exchange table with the same structure as the partitions of the partitioned table, and the exchange table having the content that you want to exchange with a partition of the partitioned table
3) Alter table exchange partition partition_name with table exchange table


Note that during the exchange all rows of the exchange table must qualify for the partition to be exchanged, otherwise the following error is thrown ORA-14099: all rows in table do not qualify for specified partition.

This is because by default the exchange is done with validation.


Example (based on SCOTT sample schema)
---------

This example creates the exchange table with the same structure as the partitions of the partitioned table p_test.

SQL> CREATE TABLE p_test
2 (sal NUMBER(7,2))
3 PARTITION BY RANGE(sal)
4 (partition emp_p1 VALUES LESS THAN (2000),
5 partition emp_p2 VALUES LESS THAN (4000));

Table created.


SQL> SELECT * FROM emp;

     EMPNO ENAME      JOB              MGR HIREDATE         SAL       COMM     DEPTNO
---------- ---------- --------- ---------- --------- ---------- ---------- ----------
      7369 SMITH      CLERK           7902 17-DEC-80        800                    20
      7499 ALLEN      SALESMAN        7698 20-FEB-81       1600        300         30
      7521 WARD       SALESMAN        7698 22-FEB-81       1250        500         30
      7566 JONES      MANAGER         7839 02-APR-81       2975                    20
      7654 MARTIN     SALESMAN        7698 28-SEP-81       1250       1400         30
      7698 BLAKE      MANAGER         7839 01-MAY-81       2850                    30
      7782 CLARK      MANAGER         7839 09-JUN-81       2450                    10
      7788 SCOTT      ANALYST         7566 19-APR-87       3000                    20
      7839 KING       PRESIDENT            17-NOV-81       5000                    10
      7844 TURNER     SALESMAN        7698 08-SEP-81       1500          0         30
      7876 ADAMS      CLERK           7788 23-MAY-87       1100                    20
      7900 JAMES      CLERK           7698 03-DEC-81        950                    30
      7902 FORD       ANALYST         7566 03-DEC-81       3000                    20
      7934 MILLER     CLERK           7782 23-JAN-82       1300                    10

14 rows selected.

SQL> CREATE TABLE exchtab1 as SELECT sal FROM emp WHERE sal<2000;

Table created.

SQL> CREATE TABLE exchtab2 as SELECT sal FROM emp WHERE sal BETWEEN 2000 AND 3999;

Table created.

SQL> alter table p_test exchange partition emp_p1 with table exchtab1;

Table altered.

SQL> alter table p_test exchange partition emp_p2 with table exchtab2;

Table altered.

D. DBMS_REDEFINITION

For details see

        Note 472449.1 How To Partition Existing Table Using DBMS_Redefinition
        Note 1481558.1  DBMS_REDEFINITION: Case Study for a Large Non-Partition Table to a Partition Table with Online Transactions occuring
        Note 177407.1 How to Re-Organize a Table Online文章来源地址https://www.toymoban.com/news/detail-499876.html

到了这里,关于parallel dml enable的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • Module的语法, JS中的 export 和 import

    在ES6之前, 社区制定了一些模块加载方案, 最主要的有CommonJS和AMD两种. 前者用于服务器,后者, 用于浏览器 ES6模块的 设计思想是尽量静态化, 使得编译时就能确定模块的依赖关系 ES6模块不是对象, 而是 通过export命令显示指定输出的代码,再通过import命令输入. 上面代码的实质是从

    2024年02月02日
    浏览(34)
  • 【ES6】require、export和import的用法

    在JavaScript中,require、export和import是Node.js的模块系统中的,用于处理模块间的依赖关系。 1、require:这是Node.js中引入模块的方法。当你需要使用其他模块提供的功能时,可以使用require来引入该模块。例如: common.js 运行 node .demo.js ,输出: 在上面的代码中,我

    2024年02月10日
    浏览(30)
  • ES6模块介绍—module的语法import、export简单介绍及用法

    模块功能主要由两个命令构成:export和import。export命令用于规定模块的对外接口,import命令用于输入其他模块提供的功能。 一个模块就是一个独立的文件。该文件内部的所有变量,外部无法获取。如果你希望外部能够读取模块内部的某个变量,就必须使用export输出该变

    2024年02月05日
    浏览(28)
  • 使用Django框架+SIMPLEUI+import_export设计公司后台管理系统

    本文详细介绍了如何在Windows系统上,使用PyCharm和Python的web开发框架Django,结合SIMPLEUI插件和import_export,来搭建一个功能全面的公司后台管理系统。

    2024年02月08日
    浏览(38)
  • 解决export ‘default‘ (imported as ‘xxx‘) was not found in ‘xxx‘

    今天写代码时出现了问题,记录一下,源代码如下 编译时警告 试了很久最后发现是import语法问题  

    2024年02月04日
    浏览(37)
  • docker export,import后无法运行,如java命令找不到,运行后容器内编码有问题

    为什么用docker export呢,😔~由于客户环境太恶心了,测试一次更是麻烦,所以什么都得在本地调试完成,争取每次测试+上线一次通过才行,说多了都是泪。 由于踩坑几次了,每次都忘记,且每次网上找半天也难以发现问题,今日决定记录一笔。 在进行docker export导出镜像,然

    2024年02月15日
    浏览(32)
  • docker使用export/import出现错误:Error response from daemon: No command specified

    之前一个使用save和load操作镜像,有次试着使用 export 和 import 来操作。 1,export导出镜像 执行下面的命令后,文件会保存到当前命令执行的目录下。 使用 docker export 命令根据容器的 ID 将镜像导出形成一个文件如下。 docker export 2af444b9693f container_save.tar 2,导入镜像 使用 docke

    2024年04月10日
    浏览(45)
  • Three.js系列-报错export ‘Geometry‘ (imported as ‘THREE‘) was not found in ‘three‘

    遇到这种报错,是因为你使用的是低版本的语法,需要修改为最新的,three.js 在 R125版本后将Geometry替换使用BufferGeometry 所以只需要搜索代码中的THREE.Geometry 小伙伴们,先写到这里啦,我们明天再见啦~~ 大家要天天开心哦 欢迎大家指出文章需要改正之处~ 学无止境,合作共赢 欢

    2024年02月08日
    浏览(37)
  • Ability to Use Oracle Data Pump to Export and Import the Unified Audit Trail

    从18c版本开始才能使用数据泵工具导出统一审计的记录

    2024年01月20日
    浏览(31)
  • 引入echars5.0报错“export ‘default‘ (imported as ‘echarts‘) was not found in ‘echarts‘解决方案

    前言:老版本的echars样式与新版本的组件美观度相差巨大,以美观为主所以把组件升级成了echars5.0,结果报错了【\\\"export ‘default’ (imported as ‘echarts’) was not found in ‘echarts’】! 直接报错:\\\"export ‘default’ (imported as ‘echarts’) was not found in \\\'echarts’ 新版本的echarts引入方式

    2024年02月03日
    浏览(40)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包