Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to join the tables of Oracle

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly introduces how to connect the table of Oracle. It is very detailed and has certain reference value. Friends who are interested must finish it.

There are four ways to join Oracle tables:

● sort merge join (Sort Merge Join)

● nested Loop join (Nested Loops Join)

● Hash connection (Hash Join)

● Cartesian product (Cartesian Product)

If the where condition has the exists, in, or = any operator + subquery, Oracle treats it as a semi-join, and the corresponding keyword in the execution plan is SEMI.

SQL > select department_id,department_name from departments d where exists (select 1 from employees e where d.department_id = e.department_id and e.salary > 2500)

11 rows selected.

Execution Plan

Plan hash value: 2188966913

-

| | Id | Operation | Name | Rows | Bytes | Cost (% CPU) | Time |

-

| | 0 | SELECT STATEMENT | | 10 | 230 | 6 (17) | 00:00:01 |

| | 1 | MERGE JOIN SEMI | | 10 | 230 | 6 (17) | 00:00:01 |

| | 2 | TABLE ACCESS BY INDEX ROWID | DEPARTMENTS | 27 | 432 | 2 (0) | 00:00:01 |

| | 3 | INDEX FULL SCAN | DEPT_ID_PK | 27 | | 1 (0) | 00:00:01 |

| | * 4 | SORT UNIQUE | | 105 | 735 | 4 (25) | 00:00:01 |

| | * 5 | TABLE ACCESS FULL | EMPLOYEES | 105 | 735 | 3 (0) | 00:00:01 |

-

SQL > select department_id,department_name from departments d where department_id in (select department_id from employees e where d.department_id = e.department_id and e.salary > 2500)

11 rows selected.

Execution Plan

Plan hash value: 2188966913

-

| | Id | Operation | Name | Rows | Bytes | Cost (% CPU) | Time |

-

| | 0 | SELECT STATEMENT | | 10 | 230 | 6 (17) | 00:00:01 |

| | 1 | MERGE JOIN SEMI | | 10 | 230 | 6 (17) | 00:00:01 |

| | 2 | TABLE ACCESS BY INDEX ROWID | DEPARTMENTS | 27 | 432 | 2 (0) | 00:00:01 |

| | 3 | INDEX FULL SCAN | DEPT_ID_PK | 27 | | 1 (0) | 00:00:01 |

| | * 4 | SORT UNIQUE | | 105 | 735 | 4 (25) | 00:00:01 |

| | * 5 | TABLE ACCESS FULL | EMPLOYEES | 105 | 735 | 3 (0) | 00:00:01 |

-

SQL > select department_id,department_name from departments d where department_id=any (select department_id from employees e where d.department_id = e.department_id and e.salary > 2500)

11 rows selected.

Execution Plan

Plan hash value: 2188966913

-

| | Id | Operation | Name | Rows | Bytes | Cost (% CPU) | Time |

-

| | 0 | SELECT STATEMENT | | 10 | 230 | 6 (17) | 00:00:01 |

| | 1 | MERGE JOIN SEMI | | 10 | 230 | 6 (17) | 00:00:01 |

| | 2 | TABLE ACCESS BY INDEX ROWID | DEPARTMENTS | 27 | 432 | 2 (0) | 00:00:01 |

| | 3 | INDEX FULL SCAN | DEPT_ID_PK | 27 | | 1 (0) | 00:00:01 |

| | * 4 | SORT UNIQUE | | 105 | 735 | 4 (25) | 00:00:01 |

| | * 5 | TABLE ACCESS FULL | EMPLOYEES | 105 | 735 | 3 (0) | 00:00:01 |

-

The above is all the contents of the article "how to connect the tables of Oracle". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report