Oracle 表訪問方式

來源:互聯網
上載者:User

本篇記錄一些Oracle表訪問方式

索引訪問方式請參考:

顯示執行計畫的預存程序請參考

(1)TABLE ACCESS FULL

全表掃表,使用全表掃描的方式訪問表。樣本:

SQL> exec sql_explain('select * from t1');
Plan hash value: 3617692013
--------------------------------------------------------------------------
| Id  | Operation        | Name | Rows  | Bytes | Cost (%CPU)| Time    |
--------------------------------------------------------------------------
|  0 | SELECT STATEMENT  |      |    10 |    80 |    3  (0)| 00:00:01 |
|  1 |  TABLE ACCESS FULL| T1  |    10 |    80 |    3  (0)| 00:00:01 |
--------------------------------------------------------------------------

PL/SQL procedure successfully completed.

(2)TABLE ACCESS BY INDEX ROWID

通過索引獲得的ROWID訪問表。

樣本:

SQL> exec sql_explain('select * from t1 where id=1');
Plan hash value: 2347959165
-------------------------------------------------------------------------------------
| Id  | Operation                  | Name  | Rows  | Bytes | Cost (%CPU)| Time    |
-------------------------------------------------------------------------------------
|  0 | SELECT STATEMENT            |      |    1 |    8 |    1  (0)| 00:00:01 |
|  1 |  TABLE ACCESS BY INDEX ROWID| T1    |    1 |    8 |    1  (0)| 00:00:01 |
|*  2 |  INDEX UNIQUE SCAN        | T1_PK |    1 |      |    0  (0)| 00:00:01 |
-------------------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
2 - access("ID"=1)

PL/SQL procedure successfully completed.

(3)LOAD AS SELECT

以(append)追加的方式向表中插入資料。

樣本:

SQL> exec sql_explain('insert /*+ append */ into t1 select * from t1');
Plan hash value: 1069440229
---------------------------------------------------------------------------
| Id  | Operation          | Name | Rows  | Bytes | Cost (%CPU)| Time    |
---------------------------------------------------------------------------
|  0 | INSERT STATEMENT  |      |    10 |    80 |    3  (0)| 00:00:01 |
|  1 |  LOAD AS SELECT    | T1  |      |      |            |          |
|  2 |  TABLE ACCESS FULL| T1  |    10 |    80 |    3  (0)| 00:00:01 |
---------------------------------------------------------------------------

PL/SQL procedure successfully completed.

  • 1
  • 2
  • 3
  • 4
  • 下一頁

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.