SQL (Structured Query Language) is the dominant language for interacting with relational databases. It’s been around since the 1970s and remains the most-used language for working with data — listed as required in essentially every data-engineering and data-science job posting.

SQL is usually described as four sub-languages, framed by what kind of operation each performs:

  • DDL — Data Definition Language. The commands that define database structures: CREATE, ALTER, DROP, RENAME, TRUNCATE.
  • DML — Data Manipulation Language. The commands that work with data inside tables: SELECT, INSERT, UPDATE, DELETE.
  • DCL — Data Control Language. The commands that manage permissions: GRANT, REVOKE.
  • TCL — Transaction Control Language. The commands that manage transactions: COMMIT, ROLLBACK, SAVEPOINT.

Most interactive querying in practice is DML, with occasional DDL when the schema changes. DCL and TCL come up less often in day-to-day work but are essential when they’re needed.

The basic shape of a query is SELECT some_columns FROM some_table WHERE some_condition — the SELECT statement picking which columns, the FROM naming the table, the WHERE clause narrowing which rows. Beyond that, real queries JOIN multiple tables together, GROUP BY one column to compute aggregates within each group, ORDER BY a column for sorted output, and LIMIT the number of rows returned.

SQL syntax is mostly portable across database management systems, but each implementation has its dialect — MySQL, PostgreSQL, Oracle, SQLite, MariaDB all extend the standard in slightly different ways. Stick to the standard core for portable code; reach for vendor-specific extensions when there’s a real reason.