Home  >  Article  >  Database  >  Statements to modify data in sql

Statements to modify data in sql

下次还敢
下次还敢Original
2024-05-01 22:06:18523browse

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

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>
where:

  • table_name is the name of the table to be updated.
  • column_name1 and column_name2 are the column names to be updated.
  • new_value1 and new_value2 are the new values ​​to be updated.
  • condition 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>
where:

  • table_name is the name of the table into which new rows are to be inserted.
  • column_name1, column_name2, etc. are the column names to be inserted into the new row.
  • value1, 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>
Where:

  • table_name is the name of the table from which rows are to be deleted.
  • condition 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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn