SQL
SQL (Structured Query Language) is the standard query language of relational databases, defining and manipulating data declaratively (DDL/DML/DQL/DCL).
Purpose
To provide a unified, declarative data-manipulation language for relational databases, decoupling applications from storage.
Mechanism
Declarative: describes "what" not "how"; the optimizer generates the execution plan. Sublanguages: DDL (CREATE/ALTER/DROP), DML (INSERT/UPDATE/DELETE), DQL (SELECT), DCL (GRANT/REVOKE). Supports subqueries, JOINs, aggregation, window functions, and CTEs.
Use cases
- Relational database query and manipulation
- Data analysis and reporting
- ETL data transformation
- ORM underlying generation
Examples
- Input
SELECT name FROM users WHERE age > 18OutputNames of adult usersDeclarative query
Common errors
- Concatenating SQL strings causes injection
- Use parameterized queries
Related terms
NoSQL
NoSQL is the umbrella term for non-relational databases, including document, key-value, column-family, and graph models, designed for scalability and flexible schemas. GLOSSARY
JOIN
JOIN is the SQL operation combining rows of multiple tables by a join condition; types include inner, left/right/full outer, and cross joins. GLOSSARY
Index
An index is an auxiliary data structure (e.g., B+ tree, hash) maintained to speed up queries, trading space for time at the cost of write overhead. GLOSSARY
Primary Key
A primary key is the column or column combination that uniquely identifies each row in a table — non-null and unique; the row identity. GLOSSARY
Transaction
A transaction is a group of operations executed as a single logical unit satisfying ACID properties — all or nothing. GLOSSARY
Related tools
SQL Formatter
Beautify or minify SQL queries online. Uppercase keywords, indent clauses, or compress to a single line. Free, private, and 100% client-side. TOOL
SQL Beautify
Pretty-print SQL with keyword uppercasing and clause indentation. TOOL
SQL Minify
Compress SQL to a single line, removing comments and extra whitespace. TOOL
SQL Normalize
Normalize SQL: uppercase keywords, single spaces, trim. TOOL
SQL Diff
Compare two SQL statements line by line. TOOL