SQL Practice Logo

SQLPractice Online

INSERT, UPDATE, DELETE Statements: Functions

Module: SQL Fundamentals

INSERT INTO employees (first_name, last_name, salary, department)

VALUES ('John', 'Doe', 75000, 'Engineering');

INSERT INTO employees (first_name, last_name, salary, department)

VALUES

('Jane', 'Smith', 80000, 'Sales'),

('Bob', 'Johnson', 70000, 'Marketing');

UPDATE employees

SET salary = salary * 1.1

WHERE department = 'Engineering';

DELETE FROM employees

WHERE employee_id = 123;

INSERT: INSERT INTO table (columns) VALUES (values)

UPDATE: UPDATE table SET col = val WHERE condition

DELETE: DELETE FROM table WHERE condition

Always use WHERE in UPDATE/DELETE (or all rows affected)

Column list in INSERT is optional but recommended

Cannot INSERT/UPDATE values that violate constraints

Core references in this topic include WHERE, =, <, >, <=, >=. Learn what each one does, when to use it, and the execution or engine rules that matter.

WHERE

Filters rows before projection and sorting. It decides which rows continue through the query pipeline.

SELECT ... FROM table WHERE condition;

Most performance issues start with a weak WHERE clause or a missing supporting index.

=

Returns rows where the left and right values are exactly equal.

column = value

Use with exact matches. Do not use = NULL.

<, >, <=, >=

Range comparison operators for less-than, greater-than, and inclusive boundary checks.

salary >= 80000

BETWEEN

Checks whether a value falls inside an inclusive lower/upper range.

order_total BETWEEN 100 AND 500

ANY / ALL

Compares one value against every or at least one value from a subquery result.

salary > ALL (SELECT salary FROM interns)

INTERVAL

Represents a duration that can be added to or subtracted from dates and timestamps.

order_date + INTERVAL '7 days'

FOREIGN KEY

Enforces referential integrity by requiring a matching row in another table.