Skip to main content

Posts

Non-Equijoins and Self-Joins in Oracle SQL

Non-Equijoins and Self-Joins in Oracle SQL Non-Equijoins and Self-Joins in Oracle SQL: Complete Guide Most joins in SQL use the equality operator. However, many real-world business requirements demand joining tables using conditions other than equality. This comprehensive guide covers two advanced and powerful join techniques: Non-Equijoins and Self-Joins . Learning Objectives By the end of this guide you will be able to write Non-Equijoins using range operators, perform Self-Joins for hierarchical data, understand performance implications, avoid common mistakes, and apply best practices in real Oracle environments. 1. Understanding Non-Equijoins A Non-Equijoin is a join that uses a comparison operator other than the equals sign. This includes > , < , >= , <= , BETWEEN , and <> . When Should You Use Non-Equijoins? Non-Equijoins are required when relationships between data are based on ranges rather than exact matches. Common business scenarios ...
Recent posts

Oracle SQL Implicit Conversion and ROWNUM Explained

Oracle SQL Implicit Conversion and ROWNUM Explained Oracle SQL: Implicit Conversion and ROWNUM Explained Oracle SQL is very flexible, but this flexibility can sometimes lead to unexpected results. Two areas where developers often face surprises are Implicit Conversion and ROWNUM . This guide explains both concepts clearly with practical examples. 1. Implicit Conversion in Oracle SQL Oracle automatically converts data types when it can. This is called implicit conversion . While convenient, it can cause performance problems and incorrect results if not understood properly. Common Implicit Conversion Scenarios Example 1: VARCHAR2 to NUMBER CREATE TABLE employees ( emp_id VARCHAR2(10), salary NUMBER ); -- This works because Oracle converts '101' to number SELECT * FROM employees WHERE emp_id = 101; Oracle converts the string '101' to number 101 to compare with the column. However, this can prevent index usage in some cases. Example ...

Oracle SQL Relational Database Concepts: Tables, Keys and Relationships

Oracle SQL: Relational Database Concepts Explained Oracle SQL: Relational Database Concepts Explained Relational databases are the foundation of modern data management systems. Oracle Database, being one of the most powerful and widely used relational database management systems in the world, is built entirely on relational database principles. If you want to truly master Oracle SQL, you must first develop a strong understanding of these fundamental concepts. In this detailed guide, we will explore every important concept step by step with clear explanations, realistic tables, practical Oracle SQL examples, diagrams, and best practices. By the end of this article, you will have a solid foundation to design efficient databases and write better SQL queries. 1. What is a Relational Database? A relational database is a type of database that stores and organizes data in the form of tables. These tables are connected to each other through well-defined relationships. The term...

Oracle SQL MERGE Statement and Advanced DML Patterns

Oracle SQL MERGE Statement and Advanced DML Patterns Oracle SQL MERGE Statement and Advanced DML Patterns MERGE solves the common "upsert" problem — when you have a source of data and need to update matching rows in a target table while inserting rows that do not yet exist, all in a single efficient operation. This guide covers the full MERGE syntax, the optional DELETE clause inside WHEN MATCHED, how to make WHEN clauses optional, proper use of DEFAULT values, the explicit DEFAULT keyword, and important rules around multi-row DML and constraint checking. In this post MERGE syntax and semantics • WHEN MATCHED with optional DELETE • Optional WHEN clauses • DEFAULT values and the DEFAULT keyword • Multi-row DML constraint behavior • Practice questions 1. MERGE — the combined INSERT/UPDATE statement MERGE solves the "upsert" problem — when you have new data in a staging table and want to update existing rows in the target while inserting new ones. ...

Oracle SQL Advanced Subqueries: Scalar, WITH Clause and DML Subqueries

Oracle SQL Advanced Subqueries: Scalar, WITH Clause and DML Subqueries Oracle SQL Advanced Subqueries: Scalar, WITH Clause and DML Subqueries — 1Z0-071 Exam Guide Advanced subqueries build on the basic subquery patterns from Chapter 8. Chapters 16 and 17 go deeper — scalar subqueries in unexpected places, the WITH clause for reusable query blocks, and subqueries used as the target of INSERT, UPDATE, and DELETE statements. These are not the most common exam questions, but they do appear — and candidates who haven't studied them lose marks that are relatively easy to pick up. In this post Scalar subqueries in SELECT and ORDER BY • Multiple-column subqueries • Pairwise vs non-pairwise comparisons • The WITH clause • Using subqueries as targets for UPDATE, INSERT, and DELETE • Practice questions 1. Scalar subqueries — one value in unexpected places A scalar subquery returns exactly one row and one column — a single value. What makes it useful is where it can be pla...

Oracle SQL SELECT Fundamentals: Columns, Aliases, DISTINCT and Expressions — 1Z0-071 Exam Guide

1Z0-071 Exam Prep Chapter 2 Volume 1 The SELECT statement is the foundation of every SQL query on the exam. Chapter 2 looks straightforward but it contains several rules that catch candidates — particularly around column aliases, the behaviour of DISTINCT with multiple columns, arithmetic on NULL, and which clauses are mandatory versus optional. This post covers the SELECT mechanics the exam actually tests, not just the basic syntax you already know. In this post SELECT statement structure and mandatory clauses Selecting all columns vs specific columns Column aliases — AS and without AS Aliases with spaces or special characters Arithmetic expressions in SELECT String concatenation with || DISTINCT — removing duplicate rows DISTINCT with multiple columns Operator precedence in expressions SQL statement rules — case, whitespace, termination Quick reference Practice questions 01 — SELECT st...