`

Oracle FORALL_Example

阅读更多
CREATE TABLE blktest (num NUMBER( 20), name varchar2( 50));

CREATE OR REPLACE PROCEDURE bulktest IS
    TYPE numtab IS TABLE OF NUMBER (20) INDEX BY BINARY_INTEGER;

    TYPE nametab IS TABLE OF VARCHAR2 (50) INDEX BY BINARY_INTEGER;
    pnums  numtab;
    pnames nametab;
    t1     NUMBER;
    t2     NUMBER;
    t3     NUMBER;
BEGIN
    FOR j IN 1 .. 1000000
    LOOP
        pnums(j) := j;
        pnames(j) := 'Seq No. ' || to_char(j);
    END LOOP ;

    SELECT dbms_utility.get_time
    INTO   t1
    FROM   dual;

    FOR i IN 1 .. 1000000
    LOOP
        INSERT INTO blktest
        VALUES
            (pnums(i)
            ,pnames(i));
    END LOOP ;

    SELECT dbms_utility.get_time
    INTO   t2
    FROM   dual;

    FORALL i IN 1 .. 1000000
        INSERT INTO blktest

        VALUES
            (pnums(i)
            ,pnames(i));

    SELECT dbms_utility.get_time
    INTO   t3
    FROM   dual;
    dbms_output.put_line( 'Execution Time (hsecs)');
    dbms_output.put_line( '---------------------');
    dbms_output.put_line( 'FOR loop: ' || to_char(t2 - t1));
    dbms_output.put_line( 'FORALL:   ' || to_char(t3 - t2));
END;

Execution Time (hsecs)
---------------------
FOR loop: 5747
FORALL:   90
  

分享到:
评论

相关推荐

    Linux__Oracle_12c_RAC安装配置v1.0.docx

    - 支持Oracle Linux 6和Red Hat Enterprise Linux 6 Distributions for x86-64 - 支持Oracle Linux 5和Red Hat Enterprise Linux 5 Distributions for x86-64 - 支持SUSE Distributions for x86-64 ##### 2.3 ...

    最全的oracle常用命令大全.txt

    ORACLE常用命令 一、ORACLE的启动和关闭 1、在单机环境下 要想启动或关闭ORACLE系统必须首先切换到ORACLE用户,如下 su - oracle a、启动ORACLE系统 oracle>svrmgrl SVRMGR>connect internal SVRMGR>startup ...

    怎么在oracle10g查询所有包含某字段的表名.doc

    假设我们要找的字段名为“example_field”,可以编写如下SQL语句: ```sql SELECT table_name FROM all_tab_columns WHERE column_name = 'example_field'; ``` 这段代码会返回所有包含“example_field”这一列的...

    plsql excel example

    5. **BULK COLLECT和FORALL**:为了提高效率,当从数据库大量导出数据时,可以使用PL/SQL的BULK COLLECT语句收集数据,然后使用FORALL语句批量插入到Excel文件。 6. **外部表**:Oracle的外部表功能允许将文件系统...

    【OracleRAC】LinuxOracle11gR2RAC安装配置详细过程V3.0(图文并茂)

    **6.6 选择“Use the Same Password for all Accounts”** 选择使用相同的密码为所有账户。 **6.7 选择“Automatic Storage Management (ASM)”** 选择使用 ASM 存储管理方式。 **6.8 配置快速恢复区** 配置...

    Oracle Core Essential Internals

    unreadable Consider for example the simple question: How does Oracle do a logical I O then take a look at structure x$kcbsw which is a list of all the functions that Oracle might call to visit a ...

    Oracle+10G+-+Plsql+User's+Guide

    The FORALL statement can handle associate arrays and nested tables with deleted elements. You can now use this performance construct in more situations than before, and avoid the need to copy elements...

    oracle asm rac

    Changing password for user oracle. New UNIX password: BAD PASSWORD: it is based on a dictionary word Retype new UNIX password: passwd: all authentication tokens updated successfully. 创建grid目录结构...

    DB2_Install_ for_linux

    3. 切换用户:`db2set DB2_COMPATIBILITY_VECTOR=ORACLE` 4. 通过新用户登录:`db2 connect to mydb user myuser using 'mypassword'` 六、备份与恢复 1. 备份数据库:`db2backup database mydb to '/backup'` 2. ...

    Oracle提高与精通

    That is the Oracle code !! You can use it improve your ability!! You know if you don't use the DATABASE and The Commnad that you...All example in the RAR File!! Hope you can use it and it can help you!!!

    oracle从基础到精通

    - Toad for Oracle - PL/SQL Developer - SQL Server Management Studio (适用于跨平台) - **SQL在编程中的应用:** - SQL通常与各种编程语言结合使用,例如Java、Python、C#等。 - 数据持久层技术如JDBC、ADO...

    Oracle sqldeveloper without jdk (win+linux)

    - The script to which the character belongs is supported by the JRE installation on which SQL Developer is running � for example, appropriate fonts are available � and - The script does not ...

    RACGuides_Rac10gR2OnLinux.pdf

    - **Example of Configuring Block Device Storage for Oracle Clusterware**:配置块设备存储的具体示例。 - **Example of Creating...** 通过上述详细的内容,我们可以看出文档提供了从软件要求、硬件配置、...

    php.ini-development

    You can redirect all of the output of your scripts to a function. For ; example, if you set output_handler to "mb_output_handler", character ; encoding will be transparently converted to the ...

    advanced oracle pl-sql

    Chapter 5, PL/Vision Package Specifications provides a brief summary of all of the specifications for the PL/Vision packages, and is marked with a thumb-tab for quick reference. Part III: Building ...

    11g_plsql_user_guide_and_reference.pdf

    For example, they can specify whether a trigger should be executed before or after a DML operation, or whether it should be executed for each row or for the entire statement. This level of control ...

    MySQL and JSON A Practical Programming Guide 2018

    Written by a MySQL Community Manager for Oracle, MySQL and JSON: A Practical Programming Guide shows how to quickly get started using JSON with MySQL and clearly explains the latest tools and ...

    SQL Assistant v5.0

    Preset code formatting rule added for Oracle VARRAY. Preset code formatting rule added for DEFAULT VALUES in INSERT/UPDATE statements in Transact-SQL. Database name and schema name completion is now...

    学习使用SQLAlchemy框架,在ORM模式下实现Python与MySQL的连接、结构设计和增删查改.zip

    users = session.query(User).all() for user in users: print(user.name, user.email) # 更新数据 john = session.query(User).filter_by(name='John').first() john.email = 'newemail@example.com' session....

    PLSQL.Developer v11.0.0.1762 主程序+ v10中文包+keygen

    Support has been added for Oracle12c extended strings (> 4000 bytes) The align button has a new Hide editor option to show only the result set The align button has a new Window width option to resize ...

Global site tag (gtag.js) - Google Analytics