[PHP]
Microsoft Windows XP [版本 5.1.2600]
(C) 版权所有 1985-2001 Microsoft Corp.
C:\Documents and Settings\Administrator>oradim -startup -sid test1
C:\Documents and Settings\Administrator>set oracle_sid=test1
C:\Documents and Settings\Administrator>sqlplus "/ as sysdba"
SQL*Plus: Release 9.2.0.4.0 - Production on 星期二 8月 28 10:50:51 2007
Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.
连接到:
Oracle9i Enterprise Edition Release 9.2.0.4.0 - Production
With the Partitioning, OLAP and Oracle Data Mining options
JServer Release 9.2.0.4.0 - Production
SQL> conn my_user/my_user
已连接。
SQL> select table_name,index_name from user_indexes;
TABLE_NAME INDEX_NAME
------------------------------ ------------------------------
TEST_PARTITION_TABLE ID_INDEX
TEST_PARTITION_TABLE MY_PK_INDEX
TEST_PARTITION_TABLE MY_UNIQUE_INDEX
TEST_PARTITION_TABLE NAME_INDEX
MY_TABLE1 PK_ID
SQL> select * from my_table1;
ID NAME MY_BIRTHDA
---------- ---------- ----------
1 name1 11-7月 -07
2 name2 24-6月 -06
SQL> select * from test_partition_table;
ID NAME MY_ID MY_UNIQUE
---------- -------------------- ---------- ----------
88 my_88 1 10
888 my_888 2 20
SQL> alter session set events '10046 trace name context forever,level 8';
会话已更改。
SQL> explain plan for select name from my_table1 where id=:1;
已解释。
SQL> alter session set events '10046 trace name context off';
会话已更改。
SQL> @?/rdbms/admin/utlxpls
PLAN_TABLE_OUTPUT
--------------------------------------------------------------------------------
---------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost |
---------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | | | |
| 1 | TABLE ACCESS BY INDEX ROWID| MY_TABLE1 | | | |
|* 2 | INDEX UNIQUE SCAN | PK_ID | | | |
---------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
PLAN_TABLE_OUTPUT
--------------------------------------------------------------------------------
2 - access("MY_TABLE1"."ID"=TO_NUMBER(:Z))
Note: rule based optimization
已选择15行。
SQL> truncate table plan_table;
表已截掉。
SQL> exec dbms_stats.gather_table_stats('MY_USER','MY_TABLE1');
PL/SQL 过程已成功完成。
SQL> alter session set events '10046 trace name context forever,level 8';
会话已更改。
SQL> explain plan for select name from my_table1 where id=:1;
已解释。
SQL> alter session set events '10046 trace name context off';
会话已更改。
SQL> @?/rdbms/admin/utlxpls
PLAN_TABLE_OUTPUT
--------------------------------------------------------------------------------
---------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost |
---------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | 9 | 2 |
| 1 | TABLE ACCESS BY INDEX ROWID| MY_TABLE1 | 1 | 9 | 2 |
|* 2 | INDEX UNIQUE SCAN | PK_ID | 2 | | 1 |
---------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
PLAN_TABLE_OUTPUT
--------------------------------------------------------------------------------
2 - access("MY_TABLE1"."ID"=TO_NUMBER(:Z))
Note: cpu costing is off
已选择15行。
SQL>
[/PHP]