There are three statements that modify data in SQL: update (UPDATE), insert (INSERT) and delete (DELETE). The UPDATE statement is used to modify the value of an existing row, the INSERT statement is used to insert new rows, and the DELETE statement is used to delete rows.
Statements to modify data in SQL
Update (UPDATE)
# The##UPDATE statement is used to modify rows of existing data in a table. The syntax is as follows:
<code class="sql">UPDATE table_name SET column_name1 = new_value1, column_name2 = new_value2 WHERE condition;</code>
is the name of the table to be updated.
and
column_name2 are the column names to be updated.
and
new_value2 are the new values to be updated.
is optional and specifies the condition for the rows to be updated.
INSERT (INSERT)
INSERT statement is used to insert new rows into a table. The syntax is as follows:
<code class="sql">INSERT INTO table_name (column_name1, column_name2, ...) VALUES (value1, value2, ...);</code>
is the name of the table into which new rows are to be inserted.
,
column_name2, etc. are the column names to be inserted into the new row.
,
value2, etc. are the new values to be inserted.
DELETE
DELETE statement is used to delete rows from a table. The syntax is as follows:
<code class="sql">DELETE FROM table_name WHERE condition;</code>
is the name of the table from which rows are to be deleted.
is optional and specifies the condition for rows to be deleted.
The above is the detailed content of Statements to modify data in sql. For more information, please follow other related articles on the PHP Chinese website!