You can use a simple UPDATE statement without a WHERE clause.
General Syntax
UPDATE table_name
SET column_name = default_value;
Without WHERE → it affects every row in the table.
With WHERE → it affects only rows matching the condition.
Example
Imagine you have a Users table:
| user_id | name | status |
|---|---|---|
| 1 | Alice | NULL |
| 2 | Bob | NULL |
| 3 | Charlie | NULL |
Now, you want to set the status column to 'Active' for all users.
✅ Here’s the SQL:
UPDATE Users
SET status = 'Active';
✅ Result:
| user_id | name | status |
|---|---|---|
| 1 | Alice | Active |
| 2 | Bob | Active |
| 3 | Charlie | Active |
Important Points
- Be careful: Without
WHERE, it affects all rows — no filtering! - You can set constants, functions, or default expressions.
- E.g., set a timestamp:
UPDATE Orders SET order_date = CURRENT_DATE;
Bonus: Reset to Default Value (if defined)
If your column has a DEFAULT value defined in the table schema, you can:
- In PostgreSQL:
UPDATE Users
SET status = DEFAULT;
But in MySQL and SQL Server, DEFAULT in UPDATE is not supported — you have to explicitly set the default value manually.
In Short
To update all rows, just omit the
WHEREclause:
✅ All rows will be updated.