Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: Would be really nice if...
Haximus wrote:
>>Possibly someone could explain how this would be beneficial as the >>fundamental concept of this request escapes me.
I disagree. Select all 50 and just ignore the two you don't need.
Consider the following:
SQL> DECLARE
2
3 l_owner dbms_sql.VARCHAR2_table; 4 l_object_name dbms_sql.VARCHAR2_table; 5 l_subobject_name dbms_sql.VARCHAR2_table; 6 l_object_id dbms_sql.NUMBER_table; 7 l_data_object_id dbms_sql.NUMBER_table; 8 l_object_type dbms_sql.VARCHAR2_table; 9 l_created dbms_sql.DATE_table; 10 l_last_ddl_time dbms_sql.DATE_table; 11 l_timestamp dbms_sql.VARCHAR2_table; 12 l_status dbms_sql.VARCHAR2_table; 13 l_temporary dbms_sql.VARCHAR2_table; 14 l_generated dbms_sql.VARCHAR2_table; 15 l_secondary dbms_sql.VARCHAR2_table;16
24 FETCH c BULK COLLECT INTO 25 l_owner, l_object_name, l_subobject_name, l_object_id, 26 l_data_object_id, l_object_type, l_created, 27 l_last_ddl_time, l_timestamp, l_status, l_temporary, 28 l_generated, l_secondary 29 LIMIT 100; 30 31 FORALL i in 1 .. l_owner.COUNT 32 INSERT INTO t1 33 (owner, object_name, subobject_name, object_id, 34 data_object_id, object_type, created, last_ddl_time 35 timestamp, status, temporary, generated, secondary) 36 VALUES 37 (l_owner(i), l_object_name(i), l_subobject_name(i), 38 l_object_id(i), l_data_object_id(i), 39 l_object_type(i), l_created(i), l_last_ddl_time(i), 40 l_timestamp(i), l_status(i), l_temporary(i), 41 l_generated(i), l_secondary(i)); 42 EXIT WHEN c%NOTFOUND;
PL/SQL procedure successfully completed.
Elapsed: 00:00:02.63
SQL> DECLARE
2
3 l_owner dbms_sql.VARCHAR2_table; 4 l_object_name dbms_sql.VARCHAR2_table; 5 l_subobject_name dbms_sql.VARCHAR2_table; 6 l_object_id dbms_sql.NUMBER_table; 7 l_data_object_id dbms_sql.NUMBER_table; 8 l_object_type dbms_sql.VARCHAR2_table; 9 l_created dbms_sql.DATE_table; 10 l_last_ddl_time dbms_sql.DATE_table; 11 l_timestamp dbms_sql.VARCHAR2_table; 12 l_status dbms_sql.VARCHAR2_table; 13 l_temporary dbms_sql.VARCHAR2_table; 14 l_generated dbms_sql.VARCHAR2_table; 15 l_secondary dbms_sql.VARCHAR2_table;16
24 FETCH c BULK COLLECT INTO 25 l_owner, l_object_name, l_subobject_name, l_object_id, 26 l_data_object_id, l_object_type, l_created, 27 l_last_ddl_time, l_timestamp, l_status, l_temporary, 28 l_generated, l_secondary 29 LIMIT 100; 30 31 FORALL i in 1 .. l_owner.COUNT 32 INSERT INTO t2 33 (owner, object_name) 34 VALUES 35 (l_owner(i), l_object_name(i)); 36 EXIT WHEN c%NOTFOUND;
PL/SQL procedure successfully completed.
Elapsed: 00:00:01.43
SQL>
In the first case I select all columns and insert all into t1.
In the second case I select all columns and use only two of them.
Where is the pain?
-- Daniel A. Morgan University of Washington damorgan_at_x.washington.edu (replace 'x' with 'u' to respond)Received on Thu Feb 24 2005 - 11:18:15 CST