Oracle WHERE Clause πΒΆ
Prerequisites: SELECT Statement
Mentor's Note: The
WHEREclause is the "Filter" of your database. It allows you to pick specific needles from the haystack of data based on rules you define. π‘
π The Scenario: The Targeted Mailing βοΈΒΆ
- Goal: You want to send a letter only to employees who earn more than βΉ50,000.
- Action: You tell Oracle: "Show me all people
WHEREsalary > 50000."
π» 1. The Basic SyntaxΒΆ
Example: Finding a specific Employee IDΒΆ
ποΈ Architect's Note: Indices & Predicates π‘οΈΒΆ
The WHERE clause is where performance is won or lost.
- The Secret: If you filter on a column that has an Index, Oracle can find the row instantly (Index Seek). If there is no index, Oracle must read the entire table (Full Table Scan).
- Architecture Tip: Always aim to filter by the Primary Key or Unique Keys whenever possible for maximum speed.