sqlcmd.net validated sql reference

#dml

Commands grouped around the same concept, pattern, or recurring problem.

15 commands with this tag Browse related patterns quickly
beginner deleting MySQL MariaDB SQL Server PostgreSQL SQLite

Delete Rows

Remove matching rows with `DELETE`, then query the remaining table contents.

advanced deleting MySQL MariaDB SQL Server PostgreSQL SQLite

Delete Rows Based On A Condition In Another Table

Remove rows from one table when a matching row exists in another table using a subquery.

advanced deleting MySQL MariaDB SQL Server PostgreSQL SQLite

Delete Rows Using A Join Condition

Remove rows from one table based on matching rows in another table.

intermediate transactions MySQL MariaDB SQL Server PostgreSQL SQLite

Group Statements Into A Transaction

Use `BEGIN`, `COMMIT`, and `ROLLBACK` to execute multiple statements as an atomic unit.

beginner inserting MySQL MariaDB SQL Server PostgreSQL SQLite

Insert a Row

Add new data to a table, then verify the inserted row with a deterministic query.

beginner inserting MySQL MariaDB SQL Server PostgreSQL SQLite

Insert Multiple Rows

Add several rows in one statement using a multi-value `INSERT`.

advanced upserting MySQL MariaDB SQL Server PostgreSQL SQLite

Insert Or Update A Row With UPSERT

Atomically insert a row if it does not exist or update it if it does, using the database's native conflict-resolution syntax.

intermediate inserting MySQL MariaDB SQL Server PostgreSQL SQLite

Insert Rows and Silently Skip Duplicates

Insert rows without raising an error when a unique constraint is violated, using each engine's conflict-ignore syntax.

beginner inserting MySQL MariaDB SQL Server PostgreSQL SQLite

Insert Rows From Another Table

Populate a table by selecting rows from another table using `INSERT INTO ... SELECT`.

advanced transactions MySQL MariaDB SQL Server PostgreSQL SQLite

Partially Roll Back With SAVEPOINT

Mark a named checkpoint inside an open transaction so you can roll back to that point without aborting the whole transaction.

advanced modification SQL Server PostgreSQL

Sync a Target Table From a Source With MERGE

Use `MERGE` to insert new rows, update matching ones, and delete rows that should be removed — all in a single statement against a source table.

intermediate updating MySQL MariaDB SQL Server PostgreSQL SQLite

Update a Column Based on Conditions With CASE WHEN

Set a column to different values depending on other column values in the same row by using `CASE WHEN` inside a `SET` clause.

beginner updating MySQL MariaDB SQL Server PostgreSQL SQLite

Update Rows

Modify existing rows with `UPDATE`, then verify the changed data with a stable query.

intermediate updating MySQL MariaDB SQL Server PostgreSQL SQLite

Update Rows Selected By A Subquery

Use a subquery in the `WHERE` clause of an `UPDATE` to restrict which rows are modified based on data from another table.

advanced updating MySQL MariaDB SQL Server PostgreSQL SQLite

Update Rows Using Values From Another Table

Use a join inside an `UPDATE` statement to copy or derive values from a related table.