varchar(10),orderid varchar(10),cost int): Table created. SQL> declare begin for j in 1..40000 loop insert into product1(recid,pid,pname,orderid, cost) values (j, 'P'||j, 'mobile','o'||j*3,j*15/4); end loop; end; / PL/SQL procedure successfully completed. SQL>select * from product; List all 40000 records here
SQL> explain plan for select * from product1;
Explained. SQL> select * from table(dbms_xplan.display); PLAN_TABLE_OUTPUT ------------------------------------------------------------------------------- Plan hash value: 427209646 ----------------------------------------------------------------------------- | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | ----------------------------------------------------------------------------- | 0 | SELECT STATEMENT | | 1 | 41 | 63 (0)| 00:00:01 | | 1 | TABLE ACCESS FULL| PRODUCT | 1 | 41 | 63 (0)| 00:00:01 | ----------------------------------------------------------------------------- Note PLAN_TABLE_OUTPUT ------------------------------------------------------------------------------- - dynamic sampling used for this statement 12 rows selected.
SQL> create unique index ind2 on product1(recid);
Index created.
SQL> select INDEX_NAME, TABLE_OWNER, TABLE_NAME, UNIQUENESS from
USER_INDEXES 2 where table_name='PRODUCT';
INDEX_NAME TABLE_OWNER TABLE_NAME UNIQUENES
------------------------------ ------------------------------ ------------------------------ --------- IND2 SYSTEM PRODUCT NONUNIQUE
SQL> select * from table(dbms_xplan.display);
PLAN_TABLE_OUTPUT -------------------------------------------------------------------------------- Plan hash value: 2374733175 -------------------------------------------------------------------------------- | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | -------------------------------------------------------------------------------- PLAN_TABLE_OUTPUT --------------------------------------------------------------------------------