select * from t1 where object_id in (select object_id from t2 where t1.object_id=t2.object_id and rownum<10);
create table t1 as select * from dba_objects
create table t2 as select * from dba_objects
子查询返回1行还是100行,都没有意义
SQL> select * from t1 where object_id in (select object_id from t2 where t1.object_id=t2.object_id and rownum<10);
已选择9行。
执行计划
----------------------------------------------------------
Plan hash value: 4165492305
-----------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
-----------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 32 | 6624 | 4736 (1)| 00:00:57 |
|* 1 | FILTER | | | | | |
| 2 | TABLE ACCESS FULL | T1 | 72109 | 14M| 228 (1)| 00:00:03 |
|* 3 | FILTER | | | | | |
|* 4 | COUNT STOPK
子查询里有rownum函数时
最新推荐文章于 2023-10-24 09:55:24 发布