How to obtain Oracle data for testing

Source: Internet
Author: User

The following article mainly tests the way Oracle data is obtained. First, we establish the relevant experimental environment. The following is an example of the relevant experimental environment, if you want to have a better understanding of how to test the Oracle Data Acquisition method, you may wish to browse the following articles.

 
 
  1. create table test as select * from dba_objects where 0=1;  
  2. create index ind_test_id on test(object_id);  
  3. insert into test select * from dba_objects  
  4. where object_id is not null and object_id>10000 order by object_id desc;  
  5. analyze table test compute statistics for table for all columns for all indexes;  
  6. Table Access Full  
  7. SQL> set autotrace trace;  
  8. SQL> select object_id from test;  
  9. set autotrace trace;  
  10. select object_id from test;  
  11. | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |  
  12. 1 | TABLE ACCESS FULL| TEST | 58650 | 229K | 239 (1)| 00:00:03 |  

Note that this is because the default value of the object_id column can be null. If it is modified to not null, how does the get method become?

 
 
  1. Index Fast Full Scan  
  2. alter table test modify(object_id not null);  
  3. select object_id from test;  
  4. | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |  
  5. 1 | INDEX FAST FULL SCAN| IND_TEST_ID | 58650 | 229K| 66 (0)| 00:00:01 |  
  6. Index Full Scan  
  7. select/*+ index(test ind_TEST_ID)*/ object_id from test;  
  8. | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |  
  9. 1 | INDEX FULL SCAN| IND_TEST_ID | 58650 | 229K| 240 (1)| 00:00:03 |  
  10. Index Range Scan  
  11. select/*+ index(test ind_TEST_ID)*/ object_id from test where object_id < 68926;  
  12. | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |  
  13. 1 | INDEX RANGE SCAN| IND_TEST_ID | 57903 | 226K| 237 (1)| 00:00:03  
  14. SQL> select object_id from test where rownum<11; INDEX FAST FULL SCAN  
  15. OBJECT_ID  
  16. 68917  
  17. 68918  
  18. 68919  
  19. 68920  
  20. 68921  
  21. 68922  
  22. 68923  
  23. 68924  
  24. 68925  
  25. 68926   

10 rows have been selected.

 
 
  1. SQL> select/*+ index(test ind_TEST_ID)*/ object_id from test where rownum<11; INDEX FULL SCAN  
  2. OBJECT_ID  
  3. 10001  
  4. 10002  
  5. 10003  
  6. 10004  
  7. 10005  
  8. 10006  
  9. 10007  
  10. 10008  
  11. 10009  
  12. 10010  

10 rows have been selected.

 
 
  1. select * from test where rownum < 2;  
  2. ....... 69554 .......  

Others focus only on the OBJECT_ID column. The above content is an introduction to the test of Oracle data acquisition methods. I hope you will get some benefits.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.