SQL Operations
Cheat sheet · https://pcornel.dk/topic.php?topic=6086
Answer
SQL operations read and change data: SELECT, INSERT, UPDATE, DELETE, plus DDL (CREATE, ALTER) and transaction control (BEGIN, COMMIT, ROLLBACK).
Remember
Run changes inside a transaction and check the affected row count before COMMIT. Always use a WHERE clause on UPDATE/DELETE and test it as a SELECT first. Use parameters, never string concatenation (SQL injection).
First checks
SELECT count(*) … WHERE …— first check for this topicpsql -c "SELECT now(), version();"— PostgreSQL reachable and versionmysql -e "SELECT NOW(), VERSION();"— MariaDB/MySQL reachable and versionsqlcmd -S <server> -Q "SELECT @@VERSION"— SQL Server reachable and version
Verify in this order
statement parsed → planned → executed in a transaction → committed
Where it usually breaks
Failures include missing or broad WHERE clauses, joins that multiply rows, implicit conversions defeating indexes, long transactions holding locks, DDL blocking workloads and assuming rollback exists for every engine/DDL operation.
SQL Operations verification boundary matrix
| Boundary | Inspect | Healthy interpretation | Do not infer |
|---|---|---|---|
| Intent | SELECT | Intended object/scope is explicit and versioned where relevant | Intent is already effective |
| Owning runtime/control plane | INSERT / UPDATE / DELETE / JOINs | Owner accepts and reports the expected object state | Downstream dependencies are healthy |
| Effective state | Filtering and aggregation | Independent read-back matches the intended state | Every client sees the same result |
| Consumer outcome | DDL basics | The original bounded check succeeds in the same time window | Production correctness outside this scope |
Read-only verification commands unless stated otherwise. Confirm syntax for your platform and release. Full reference: https://pcornel.dk/topic.php?topic=6086