SPECS


SQL


Structured Query Language


For full documentation visit iso.org/standard.

For general information visit en.wikipedia.org/wiki/SQL.


SQL, which stands for Structured Query Language, is the standard domain-specific programming language used to manage, manipulate, and retrieve data stored in relational database management systems (RDBMS). Pronounced either as individual letters or as "sequel," SQL uses a declarative approach where you describe what data you want rather than how to physically find it. It is a foundational tool for data analysts, backend developers, and data scientists across the tech industry.


Key Characteristics of SQL

  • Declarative Nature: You specify the desired outcome using English-like commands (e.g., SELECT name FROM users), leaving execution optimization to the database engine.

  • Tabular Structure: SQL interacts specifically with data organized into rows (records) and columns (attributes) within tables.

  • Platform Independence: While different database vendors include unique extensions, they all adhere to core ANSI and ISO standards.


The Five Sub-Languages of SQL

SQL commands are categorized into five sub-languages based on their functional purpose:


Data Query Language (DQL):

  • Used to fetch data from the database.
  • Primary Command: SELECT.


Data Manipulation Language (DML):

  • Used to modify data records.
  • Primary Commands: INSERT, UPDATE, DELETE.


Data Definition Language (DDL):

  • Used to define and modify the database structure.
  • Primary Commands: CREATE, ALTER, DROP, TRUNCATE.


Data Control Language (DCL):

  • Used to manage security permissions and access control.
  • Primary Commands: GRANT, REVOKE.


Transaction Control Language (TCL):

  • Used to manage changes made by DML statements to ensure data integrity.
  • Primary Commands: COMMIT, ROLLBACK.Popular SQL Database Systems


Step-by-Step Example

Here is a practical, sequential breakdown of how SQL works from building a table to pulling data out of it.


1. Creating a Table (DDL)

This script creates a structured table named employees to hold unique IDs, names, departments, and monthly salaries.

CREATE TABLE employees (
    employee_id INT PRIMARY KEY,
    first_name VARCHAR(50),
    department VARCHAR(50),
    salary DECIMAL(10, 2)
);


2. Inserting Data (DML)

Once the layout is ready, you can add records to populate the table.

INSERT INTO employees (employee_id, first_name, department, salary) 
VALUES 
(1, 'Alice', 'Engineering', 85000.00),
(2, 'Bob', 'Sales', 60000.00),
(3, 'Charlie', 'Engineering', 95000.00),
(4, 'Diana', 'Marketing', 55000.00);


3. Querying the Data (DQL)

If you want to view only the engineers who earn more than $80,000, you use a targeted query.

SELECT first_name, salary 
FROM employees
WHERE department = 'Engineering' AND salary > 80000.00;


The Output Result:

first_name salary
Alice 85000.00
Charlie 95000.00


4. Updating Records (DML)

If Bob gets a raise, you alter his specific row using the UPDATE command filtered by his identifier.

UPDATE employees 
SET salary = 65000.00 
WHERE employee_id = 2;


Most enterprise-level relational databases rely on SQL, though many use their own procedural flavors (like Microsoft's T-SQL or Oracle's PL/SQL) to add variables and loops:


  • MySQL: A widely used, open-source RDBMS that powers millions of websites.

  • PostgreSQL: An advanced, highly scalable open-source object-relational database.

  • Microsoft SQL Server: A comprehensive commercial database system built for enterprise environments.

  • Oracle Database: A powerful, multi-model database widely used in corporate and financial applications.

  • SQLite: A lightweight, file-based database embedded natively inside mobile phones and web browsers.


Programming Languages


More Coding Languages



Social Media




---
title: SQL
text: Structured Query Language
image: /assets/svg/sql.svg
link: 
target: 
---