DML
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.
Check yourself
Exercise review
The mentor knows the solution and will help you reach it independently
Sign in to use the Mentor
The Mentor uses the current exercise and your conversation history.
Sign in
Review the key nuances and the answer after making your own attempt.
Sign in to view the solution
The solution and explanation are available after signing in.
Sign in