Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

Row Generating in faster way

Adme12Jan 16 2014 — edited Jan 24 2014

Hello Experts

I need a script, which fills my table with test data up.

What are your opinion, could this script be tuned?

CREATE TABLE TEST_TAB

(  id_test   NUMBER(10)

, x_domain  VARCHAR2(1)

, id_object NUMBER(10)

)

TABLESPACE ALL_DATA

/

id_test  : This is the primary key. It should goes from 1 to 10 000 000.

x_domain : It has 3 values and the distribution should be so:

           M : 94 %    (M = Main)

           S : 4  %    (S = Sub)

           O : 2  %    (O = Other)

id_object : Random number between 0 and 10 000 000

SET TERMOUT ON SERVEROUTPUT ON

DECLARE

   v_start       TIMESTAMP(6);

   v_end         TIMESTAMP(6);

BEGIN

   EXECUTE IMMEDIATE 'TRUNCATE TABLE TEST_TAB';

   v_start := CURRENT_TIMESTAMP;

   INSERT /*+ APPEND PARALLEL (16) */

     INTO TEST_TAB (id_test, x_domain, id_object)

   SELECT LEVEL AS ID_TEST

        , CASE WHEN level <= 10000000/100*94                              THEN 'M'

               WHEN level  > 10000000/100*94 AND level <= 10000000/100*98 THEN 'S'

             ELSE 'O'

          END AS X_DOMAIN

        , TRUNC(dbms_random.value(0, 10000000)) AS ID_OBJECT

     FROM DUAL

   CONNECT BY LEVEL <= 10000000

   ;

   COMMIT;

   v_end := CURRENT_TIMESTAMP;

   DBMS_OUTPUT.PUT_LINE('Insert took : ' || TO_CHAR(v_end-v_start));

END;

/

SQL*Plus: Release 11.2.0.1.0 Production on Thu Jan 16 11:21:43 2014

Copyright (c) 1982, 2010, Oracle.  All rights reserved.

Connected to:

Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production

With the Partitioning, OLAP, Data Mining and Real Application Testing options

Insert took : +000000000 00:02:12.020934000

PL/SQL procedure successfully completed.

SQL>

I have read from rp0428 that firstly we have to use SQL and not PL/SQL. But it seems for me that this sql took too long time.. Can it be tuned?

This post has been answered by Adme12 on Jan 20 2014
Jump to Answer

Comments

Srini Chavali-Oracle
Pl be aware that currently only 11.2.0.3 is certified with Linux 6.x - http://docs.oracle.com/cd/E11882_01/relnotes.112/e23558/toc.htm#CHDFHIEA - and 11.2.0.3 is only available on My Oracle Support (https://support.oracle.com) for customers with a paid support contract.

If you are using 11.2.0.1 then you will need to use Linux 5.x

HTH
Srini
Abhijit
Srini - I am trying to install 11.2.0.3 on OEL 6.4, not an older version. I think the check script is old and need to be updated.
Srini Chavali wrote:
Pl be aware that currently only 11.2.0.3 is certified with Linux 6.x - http://docs.oracle.com/cd/E11882_01/relnotes.112/e23558/toc.htm#CHDFHIEA - and 11.2.0.3 is only available on My Oracle Support (https://support.oracle.com) for customers with a paid support contract.

If you are using 11.2.0.1 then you will need to use Linux 5.x

HTH
Srini
Srini Chavali-Oracle
Have you installed the Oracle-validated rpm ? Which version of Linux 6.4 are you using - 32-bit or 64-bit ? Which version of 11.2.0.3 - 32-bit or 64-bit ?

HTH
Srini
Abhijit
>

Yes, OEL 6.4 64bit, 11.2.0.3 64bit.
Have you installed the Oracle-validated rpm ? Which version of Linux 6.4 are you using - 32-bit or 64-bit ? Which version of 11.2.0.3 - 32-bit or 64-bit ?

HTH
Srini
Srini Chavali-Oracle
Then pl open an SR with Support - if everything is 64-bit, it should not be asking for 32-bit RPMs

HTH
Srini
Abhijit
I need to ask my DBA to open an SR. My contact within Oracle said that the check script need to be updated for OEL 6.4 and it was safe to ignore and continue with the installation. Applying the 11.2.0.3 patch now. Thanks for your time.
Srini Chavali wrote:
Then pl open an SR with Support - if everything is 64-bit, it should not be asking for 32-bit RPMs

HTH
Srini
1 - 6
Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Feb 21 2014
Added on Jan 16 2014
42 comments
6,984 views