DML

Basic SQL
≈ 1 min read

DML works with table rows

DML — Data Manipulation Language — is used to change the data itself. The main operations are inserting a row, updating existing rows, and deleting rows.

INSERT, UPDATE, and DELETE

INSERT INTO users (id, name)
VALUES (1, 'Anna');

UPDATE users
SET name = 'Maria'
WHERE id = 1;

DELETE FROM users
WHERE id = 1;

INSERT adds a new row. UPDATE changes values in existing rows, while DELETE removes rows. In the example, conditions limit the update and deletion to one record.

Be especially careful with UPDATE and DELETE. If an update or delete statement is not limited to the intended rows, it can affect much more data than expected. We will study conditions in detail in the next section of the course.

Different sources may classify some statements slightly differently. In practice, it matters more to understand whether a statement changes database structure, changes table contents, or only reads data.