In SQL, the INSERT
, UPDATE
, and DELETE
statements are used to manipulate database rows in different ways:
INSERT:
The INSERT
statement is used to add new rows or records into a table. It allows you to specify the values for each column of the table or insert data from another source, such as a subquery or another table.
The basic syntax for the INSERT
statement is as follows:
...
This will add a new employee with the specified details to the "Employees" table.
UPDATE:
The UPDATE
statement is used to modify existing rows in a table. It allows you to change the values of one or more columns in the table based on certain conditions.
The basic syntax for the UPDATE
statement is as follows:
...
This will change the "Age" to 32 and the "Department" to "Marketing" for the employee with EmployeeID 1.
DELETE:
The DELETE
statement is used to remove rows from a table. It allows you to delete one or more rows that match a specified condition.
The basic syntax for the DELETE
statement is as follows:
...