Introducing arrays and bulk operations

In this recipe, we will see different ways to insert data in our tables and we will make some considerations about the INSERT statement's performance.

We will see how arrays can be used to speed up insert and select statements, and why it may be better to use a single statement to achieve certain goals than using a procedural approach.

How to do it...

The following steps will demonstrate the use of arrays to insert data into the tables:

  1. Connect to the SH schema:
    CONNECT sh@TESTDB/sh
    
  2. Create an empty table called MY_SALES with the same structure as the SALES table:
    CREATE TABLE sh.MY_SALES AS
      SELECT cust_id, prod_id FROM sh.sales WHERE 1=0;
    
  3. Enable timing:
    SET TIMING ON
    
  4. Create a PL/SQL block to insert the sales ...

Get Oracle Database 11gR2 Performance Tuning Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.