1. 程式人生 > >select dummy 與 select sysdate的區別

select dummy 與 select sysdate的區別

select  dummy from dual ,select  sysdate from dual之間的區別在哪裡呢;

下面來看一下:
SQL> set autotra traceonly exp
SQL> select dummy from dual;

Execution Plan
----------------------------------------------------------
Plan hash value: 272002086
--------------------------------------------------------------------------
| Id  | Operation         | Name | Rows  | Bytes | Cost (%CPU)| Time     |
--------------------------------------------------------------------------
|   0 | SELECT STATEMENT  |      |     1 |     2 |     2   (0)| 00:00:01 |
|   1 |  TABLE ACCESS FULL| DUAL |     1 |     2 |     2   (0)| 00:00:01 |
--------------------------------------------------------------------------

SQL> select sysdate from dual;
Execution Plan
----------------------------------------------------------
Plan hash value: 1388734953
----------------------------------------------------------------
| Id  | Operation        | Name | Rows  | Cost (%CPU)| Time     |
-----------------------------------------------------------------
|   0 | SELECT STATEMENT |      |     1 |     2   (0)| 00:00:01 |
|   1 |  FAST DUAL       |      |     1 |     2   (0)| 00:00:01 |
-----------------------------------------------------------------
SQL> 

從實行計劃,可以看出前者是一個 邏輯讀操作;而後者就好比是一個對 函式的呼叫,是不需要邏輯讀的;