Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: Oracle For Fun

Re: Oracle For Fun

From: KDB <itzkdb_at_rediffmail.com>
Date: 27 Jan 2004 03:19:51 -0800
Message-ID: <c8ca7368.0401270319.3d63bc4f@posting.google.com>


What do you say about this:

CREATE TABLE t1 AS
SELECT *
FROM all_objects
WHERE 1=0; CREATE OR REPLACE PROCEDURE test_proc IS

BEGIN
    INSERT /*+ APPEND */ INTO t1
    (owner, object_name, subobject_name, object_id,

     data_object_id, object_type, created, last_ddl_time,
     timestamp, status, temporary, generated, secondary)
    select owner, object_name, subobject_name, object_id,
     data_object_id, object_type, created, last_ddl_time,
     timestamp, status, temporary, generated, secondary from all_objects nologging;
  COMMIT;
END test_proc;
/

set timing on
exec test_proc;
set timing off

Daniel Morgan <damorgan_at_x.washington.edu> wrote in message news:<1075188942.399322_at_yasure>...
> At a class I taught this last weekend I brought up the fact that most
> PL/SQL programmers are still writing v7 code. I gave everyone there a
> challenge and thought I'd share it with the group for any of you looking
> for a challenge on which to sharpen your skills.
>
> CREATE TABLE t1 AS
> SELECT *
> FROM all_objects
> WHERE 1=0;
>
> CREATE OR REPLACE PROCEDURE test_proc IS
>
> BEGIN
> FOR x IN (SELECT * FROM all_objects)
> LOOP
> INSERT INTO t1
> (owner, object_name, subobject_name, object_id,
> data_object_id, object_type, created, last_ddl_time,
> timestamp, status, temporary, generated, secondary)
> VALUES
> (x.owner, x.object_name, x.subobject_name, x.object_id,
> x.data_object_id, x.object_type, x.created,
> x.last_ddl_time, x.timestamp, x.status, x.temporary,
> x.generated, x.secondary);
> END LOOP;
> COMMIT;
> END test_proc;
> /
>
> set timing on
> exec test_proc;
> set timing off
>
> Everyone using 8i+ features should be able to improve the performance of
> this by at least 5X.
>
> I'll post a solution in a week or so.
Received on Tue Jan 27 2004 - 05:19:51 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US