Home >Database >SQL >How to write modification statements in sql

How to write modification statements in sql

下次还敢
下次还敢Original
2024-05-07 06:15:301227browse

Modification statements in SQL include UPDATE, DELETE and INSERT INTO, which are used to update, delete and insert data in the database. The UPDATE statement updates existing records in the table, the DELETE statement deletes records, and the INSERT INTO statement inserts new records.

How to write modification statements in sql

Modify statement in SQL

Modify statement is used to update data in the database, and it includes the following commands:

  • UPDATE
  • DELETE
  • INSERT INTO

UPDATE statement

The UPDATE statement is used to update existing records in the table. Its format is:

<code>UPDATE <表名>
SET <列名> = <新值>, ...
WHERE <条件>;</code>

For example, update the employees table The salary of the employee named "John Doe" is 10,000:

<code>UPDATE employees
SET salary = 10000
WHERE name = "John Doe";</code>

DELETE statement

The DELETE statement is used to delete records from the table. Its format is:

<code>DELETE FROM <表名>
WHERE <条件>;</code>

For example, to delete an employee named "John Doe" from the employees table:

<code>DELETE FROM employees
WHERE name = "John Doe";</code>

INSERT INTO statement

The INSERT INTO statement is used to insert new records into the table. Its format is:

<code>INSERT INTO <表名> (<列名1>, <列名2>, ...)
VALUES (<值1>, <值2>, ...);</code>

For example, insert a new employee "Jane Smith" in the employees table:

<code>INSERT INTO employees (name, salary)
VALUES ("Jane Smith", 8000);</code>

The above is the detailed content of How to write modification statements 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