# Basic SQL Commands

> Basic SQL commands are the five statements that cover most everyday database work: CREATE defines a new table and its structure, SELECT reads rows, INSERT adds new rows, UPDATE changes existing rows that match a condition, and DELETE removes rows that match a condition. Each command does exactly one job.

Canonical: https://devsunite.com/resources/core-subjects/dbms/basic-sql-commands
Last updated: 2026-11-22

Subject: DBMS · Category: SQL · 3 min read

A small handful of SQL commands account for the overwhelming majority of real-world database work. Understanding these five deeply, rather than memorizing every possible SQL feature, covers what almost every application actually does with its database.

## The five core commands

1. **CREATE**: defines a new table (or database, view, index) and its structure.
2. **SELECT**: reads rows out of one or more tables, optionally filtered, sorted, and limited.
3. **INSERT**: adds new rows to a table.
4. **UPDATE**: changes existing rows that match a condition.
5. **DELETE**: removes existing rows that match a condition.

## A worked example, all five in sequence

```sql
CREATE TABLE tasks (
    task_id INT PRIMARY KEY,
    title VARCHAR(200),
    is_done BOOLEAN DEFAULT false
);

INSERT INTO tasks (task_id, title) VALUES (1, 'Write report');
INSERT INTO tasks (task_id, title) VALUES (2, 'Review PR');

SELECT * FROM tasks WHERE is_done = false;
-- returns both rows, since is_done defaults to false

UPDATE tasks SET is_done = true WHERE task_id = 1;

SELECT * FROM tasks WHERE is_done = false;
-- now returns only task_id 2

DELETE FROM tasks WHERE is_done = true;

SELECT * FROM tasks;
-- returns only task_id 2, the completed one was removed
```

Each command does exactly one job: `CREATE` sets up the shape, `INSERT` populates it, `SELECT` reads it back with a real filter condition, `UPDATE` changes a matching row in place, and `DELETE` removes a matching row entirely.

## A critical warning worth stating plainly

`UPDATE` and `DELETE` without a `WHERE` clause apply to every single row in the table. `DELETE FROM tasks;` with no `WHERE` clause deletes every row in the table, not just one. This is one of the most common and most damaging real mistakes made against production databases, always double-check the `WHERE` clause before running an `UPDATE` or `DELETE`, ideally by first running the equivalent `SELECT` with the same condition to see exactly which rows would be affected.

## Where this matters in real systems

Because of the real risk above, production database access is often restricted so that ordinary application code can only run parameterized, pre-reviewed queries, and direct ad-hoc `UPDATE`/`DELETE` access to production data is treated as a genuinely dangerous operation requiring extra caution or a second reviewer, exactly because a missing `WHERE` clause can silently wipe out an entire table in production in under a second.

## What interviewers actually ask about basic SQL commands

- **"What are the five most commonly used SQL commands?"** CREATE, SELECT, INSERT, UPDATE, DELETE.
- **"What happens if you run UPDATE or DELETE without a WHERE clause?"** It applies to every row in the table, changing or deleting all of them, not just one.
- **"How would you safely test a DELETE before running it?"** Run the equivalent SELECT with the same WHERE condition first, to see exactly which rows would be affected.
- **"What's the difference between DELETE and UPDATE?"** DELETE removes matching rows entirely; UPDATE changes specific column values on matching rows while keeping the row itself.

## Key takeaways

- CREATE, SELECT, INSERT, UPDATE, and DELETE cover the large majority of everyday SQL work.
- SELECT reads data with a filter, INSERT adds new rows, UPDATE changes existing rows, DELETE removes them.
- UPDATE and DELETE without a WHERE clause affect every row in the table, a real and common source of accidental data loss.
- Testing a DELETE's WHERE clause with an equivalent SELECT first is a genuinely useful safety habit.

## Related

- [Previous: SQL Data Types](https://devsunite.com/resources/core-subjects/dbms/sql-datatypes)
- [Next: Other SQL Commands](https://devsunite.com/resources/core-subjects/dbms/other-sql-commands)
- [More in SQL: Introduction to SQL](https://devsunite.com/resources/core-subjects/dbms/introduction-to-sql)
- [More in SQL: SQL Aggregate Functions](https://devsunite.com/resources/core-subjects/dbms/aggregate-functions)
- [More in SQL: SQL Joins](https://devsunite.com/resources/core-subjects/dbms/sql-joins)
- [More in SQL: SQL Views](https://devsunite.com/resources/core-subjects/dbms/sql-views)
- [More in SQL: SQL Indexes](https://devsunite.com/resources/core-subjects/dbms/sql-indexes)
- [More in SQL: SQL Subqueries](https://devsunite.com/resources/core-subjects/dbms/sql-subqueries)
- [More in SQL: SQL Stored Procedures](https://devsunite.com/resources/core-subjects/dbms/sql-stored-procedures)
- [All 174 DBMS interview questions](https://devsunite.com/resources/core-subjects/dbms)
