分类: Oracle
2018-03-19 15:50:39
点击(此处)折叠或打开
点击(此处)折叠或打开
SQL> SQL>
COL1 COL2 COL3
------------ ------------ ------------------------
AAAA
BBBB 2222
CCC1 CCCC3331
CCC2 CCCC3332
DDDD 4444 DDDD4444
SQL> SQL>
PL/SQL procedure successfully completed.
SQL> SQL>
NUM_ROWS
----------
3 <-- col3 不是空的记录在这里,不包括col3是空的。
SQL>
NUM_ROWS
----------
2 <-- col2 不是空的记录在这里,不包括col2是空的。
SQL> SQL> SQL> SQL>
Execution Plan
----------------------------------------------------------
Plan hash value: 3172374036
-------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
-------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | 5 | 3 (0)| 00:00:01 |
|* 1 | TABLE ACCESS FULL| TESTINDEX | 1 | 5 | 3 (0)| 00:00:01 |
-------------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
1 - filter("COL1"='AAAA')
SQL>
Execution Plan
----------------------------------------------------------
Plan hash value: 3172374036
-------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
-------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | 5 | 3 (0)| 00:00:01 |
|* 1 | TABLE ACCESS FULL| TESTINDEX | 1 | 5 | 3 (0)| 00:00:01 |
-------------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
1 - filter("COL1"='DDDD')
SQL> SQL>
Execution Plan
----------------------------------------------------------
Plan hash value: 2159720071
--------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
--------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | 3 | 3 (0)| 00:00:01 |
| 1 | SORT AGGREGATE | | 1 | 3 | | |
|* 2 | TABLE ACCESS FULL| TESTINDEX | 3 | 9 | 3 (0)| 00:00:01 |
--------------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
2 - filter("COL2" IS NULL)
SQL> SQL>
Execution Plan
----------------------------------------------------------
Plan hash value: 2605560524
----------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
----------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | 3 | 1 (0)| 00:00:01 |
|* 1 | INDEX RANGE SCAN| INDEX_2 | 1 | 3 | 1 (0)| 00:00:01 |
----------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
1 - access("COL2"='2222')
SQL>
点击(此处)折叠或打开
SQL> SQL>
COL1 COL2 COL3
------------ ------------ ------------------------
AAAA
BBBB 2222
CCC1 CCCC3331
CCC2 CCCC3332
DDDD 4444 DDDD4444
SQL> SQL>
PL/SQL procedure successfully completed.
SQL> SQL>
NUM_ROWS
----------
5 <-- 所有记录都在这里了
SQL>
NUM_ROWS
----------
5
SQL> SQL> SQL> SQL>
Execution Plan
----------------------------------------------------------
Plan hash value: 3172374036
-------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
-------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | 5 | 3 (0)| 00:00:01 |
|* 1 | TABLE ACCESS FULL| TESTINDEX | 1 | 5 | 3 (0)| 00:00:01 |
-------------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
1 - filter("COL1"='AAAA')
SQL>
Execution Plan
----------------------------------------------------------
Plan hash value: 3172374036
-------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
-------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | 5 | 3 (0)| 00:00:01 |
|* 1 | TABLE ACCESS FULL| TESTINDEX | 1 | 5 | 3 (0)| 00:00:01 |
-------------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
1 - filter("COL1"='DDDD')
SQL> SQL>
Execution Plan
----------------------------------------------------------
Plan hash value: 536543931
-----------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
-----------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | 3 | 1 (0)| 00:00:01 |
| 1 | SORT AGGREGATE | | 1 | 3 | | |
|* 2 | INDEX RANGE SCAN| INDEX_2 | 3 | 9 | 1 (0)| 00:00:01 |
-----------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
2 - access("COL2" IS NULL)
SQL> SQL>
Execution Plan
----------------------------------------------------------
Plan hash value: 2605560524
----------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
----------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | 3 | 1 (0)| 00:00:01 |
|* 1 | INDEX RANGE SCAN| INDEX_2 | 1 | 3 | 1 (0)| 00:00:01 |
----------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
1 - access("COL2"='2222')
SQL>