link: Relational Databases

SQL Operations

Overview

Structured Query Language (SQL) is the primary language used for interacting with relational databases. It encompasses a range of commands categorized into Data Definition Language (DDL), Data Manipulation Language (DML), Data Control Language (DCL), and Transaction Control Language (TCL), each serving distinct purposes in database management and manipulation.

SQL Command Categories

SQL also includes advanced features and clauses that enhance querying and data manipulation capabilities:

Enhanced Query Capabilities

  • JOIN: Combines rows from two or more tables based on a related column.
  • WHERE: Filters records to include only those that meet a specified condition.
  • DISTINCT: Eliminates duplicate records from the results.
  • GROUP BY: Groups rows sharing a property into summary rows.
  • HAVING: Filters records that work on aggregated results.
  • ORDER BY: Specifies the order in which to return the rows.
  • LIMIT: Restricts the number of rows returned.
  • UNION, UNION ALL, INTERSECT, EXCEPT: Combine results from multiple SELECT statements.

Advanced SQL Features

This section delves into sophisticated SQL capabilities that enable more complex operations and greater control over database transactions and data manipulation:

  • SQL Advanced Features: Reusable SQL scripts that can perform operations such as data validation or complex calculations within the database server, reducing client-server communication. (Functions)
  • SQL Triggers and Events: Automatically executed actions in response to specific changes or events within the database, ensuring data integrity and automating routine tasks.
  • Advanced Querying Techniques: Includes using window functions for data over sets of rows, and recursive queries which are essential for dealing with hierarchical or nested data structures.