删除语句批处理中是否存在运算符?
Exists operator in delete statement batch process?
我想知道进程的顺序,先执行什么..
首先我创建 table =>
SQL> create table ramin.tab001 ( id number, name varchar2(20));
Table created.
SQL> select *from ramin.tab001;
ID NAME
---------- --------------------
1 kamran
2 emin
3 ramin
4 john
在此之后,我在选项上使用带有自动跟踪的相关子查询=>
SQL>delete from ramin.tab001 a where exists( select * from ramin.tab001 where id = a.id );
执行计划=>
Execution Plan
----------------------------------------------------------
Plan hash value: 906765530
------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
------------------------------------------------------------------------------
| 0 | DELETE STATEMENT | | 6 | 36 | 6 (0)| 00:00:01 |
| 1 | DELETE | TAB001 | | | | |
|* 2 | HASH JOIN SEMI | | 6 | 36 | 6 (0)| 00:00:01 |
| 3 | TABLE ACCESS FULL| TAB001 | 6 | 18 | 3 (0)| 00:00:01 |
| 4 | TABLE ACCESS FULL| TAB001 | 6 | 18 | 3 (0)| 00:00:01 |
------------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
2 - access("ID"="A"."ID")
Statistics
----------------------------------------------------------
0 recursive calls
7 db block gets
6 consistent gets
0 physical reads
1204 redo size
848 bytes sent via SQL*Net to client
1005 bytes received via SQL*Net from client
3 SQL*Net roundtrips to/from client
1 sorts (memory)
0 sorts (disk)
4 rows processed
我知道进程的相关子查询顺序是=>
1. 执行内部查询
2. 执行外层查询并与内层查询的结果进行比较
所以我需要专家对声明中的流程顺序或我如何从自动跟踪中进行检查的意见?
如何读取执行计划?
答案很简单。像阅读命令式语言中的多层嵌套函数调用一样阅读它。
例如,你的执行计划
------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
------------------------------------------------------------------------------
| 0 | DELETE STATEMENT | | 6 | 36 | 6 (0)| 00:00:01 |
| 1 | DELETE | TAB001 | | | | |
|* 2 | HASH JOIN SEMI | | 6 | 36 | 6 (0)| 00:00:01 |
| 3 | TABLE ACCESS FULL| TAB001 | 6 | 18 | 3 (0)| 00:00:01 |
| 4 | TABLE ACCESS FULL| TAB001 | 6 | 18 | 3 (0)| 00:00:01 |
------------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
2 - access("ID"="A"."ID")
可以简单地阅读(以命令式伪代码的形式)
delete(
from: "TAB001",
data_set_to_be_deleted: semi_join(
join_algorithm: "hash join",
leading_data_set: table_access(
read_access_method: "full",
table_name: "TAB001"
),
trailing_data_set: table_access(
read_access_method: "full",
table_name: "TAB001",
aliased_as: "A"
),
join_condition: "ID = A.ID"
)
)
我想知道进程的顺序,先执行什么..
首先我创建 table =>
SQL> create table ramin.tab001 ( id number, name varchar2(20));
Table created.
SQL> select *from ramin.tab001;
ID NAME
---------- --------------------
1 kamran
2 emin
3 ramin
4 john
在此之后,我在选项上使用带有自动跟踪的相关子查询=>
SQL>delete from ramin.tab001 a where exists( select * from ramin.tab001 where id = a.id );
执行计划=>
Execution Plan
----------------------------------------------------------
Plan hash value: 906765530
------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
------------------------------------------------------------------------------
| 0 | DELETE STATEMENT | | 6 | 36 | 6 (0)| 00:00:01 |
| 1 | DELETE | TAB001 | | | | |
|* 2 | HASH JOIN SEMI | | 6 | 36 | 6 (0)| 00:00:01 |
| 3 | TABLE ACCESS FULL| TAB001 | 6 | 18 | 3 (0)| 00:00:01 |
| 4 | TABLE ACCESS FULL| TAB001 | 6 | 18 | 3 (0)| 00:00:01 |
------------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
2 - access("ID"="A"."ID")
Statistics
----------------------------------------------------------
0 recursive calls
7 db block gets
6 consistent gets
0 physical reads
1204 redo size
848 bytes sent via SQL*Net to client
1005 bytes received via SQL*Net from client
3 SQL*Net roundtrips to/from client
1 sorts (memory)
0 sorts (disk)
4 rows processed
我知道进程的相关子查询顺序是=>
1. 执行内部查询
2. 执行外层查询并与内层查询的结果进行比较
所以我需要专家对声明中的流程顺序或我如何从自动跟踪中进行检查的意见?
如何读取执行计划?
答案很简单。像阅读命令式语言中的多层嵌套函数调用一样阅读它。
例如,你的执行计划
------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
------------------------------------------------------------------------------
| 0 | DELETE STATEMENT | | 6 | 36 | 6 (0)| 00:00:01 |
| 1 | DELETE | TAB001 | | | | |
|* 2 | HASH JOIN SEMI | | 6 | 36 | 6 (0)| 00:00:01 |
| 3 | TABLE ACCESS FULL| TAB001 | 6 | 18 | 3 (0)| 00:00:01 |
| 4 | TABLE ACCESS FULL| TAB001 | 6 | 18 | 3 (0)| 00:00:01 |
------------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
2 - access("ID"="A"."ID")
可以简单地阅读(以命令式伪代码的形式)
delete(
from: "TAB001",
data_set_to_be_deleted: semi_join(
join_algorithm: "hash join",
leading_data_set: table_access(
read_access_method: "full",
table_name: "TAB001"
),
trailing_data_set: table_access(
read_access_method: "full",
table_name: "TAB001",
aliased_as: "A"
),
join_condition: "ID = A.ID"
)
)