To highlight more important topics in database operations, the following is pinned.
Guidelines for updating and deleting data :
- Do not use the WHERE clause when performing an update or delete, unless you really intend to update or delete each row.
- Make sure that each table has a primary key, and that it is used whenever possible to use a WHERE clause.
- Before using an update or delete with a WHERE clause, test with the SELECT statement to ensure that the correct records are filtered.
- When using a database, referential integrity is enforced so that MARIADB does not allow the deletion of rows whose data is associated with data in other tables.
Update data
UPDATE Customers SET = ' [email protected] ' WHERE = 10005;
To update multiple columns :
UPDATE Customers SET = ' The Fudds ' , = ' [email protected] ' WHERE = 10005;
If you update multiple rows with the UPDATE statement, and the update one or more rows produces an error, the entire update operation is canceled.
In order to continue the update operation even if an error occurs, you can use the keyword ignore
UPDATE IGNORE customers ...
Delete column values ( not delete data ):
UPDATE Customers SET = NULL WHERE = 10005;
Delete data
DELETE from Customers WHERE = 10006;
The DELETE statement removes a separate row from the table.
Delete always deletes the contents of the table, not the table itself. Even if all rows in the table are deleted, the DELETE statement does not delete the table itself.
Faster deletion: If you really want to clear all the rows in the table, do not use Delete, but instead use the TRUNCATE table statement.
MariaDB SQL Update and delete data