Home > Database > SQL > body text

How to write modification statements in sql

下次还敢
Release: 2024-05-07 06:15:30
Original
1181 people have browsed it

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>
Copy after login

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>
Copy after login

DELETE statement

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

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

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

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

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>
Copy after login

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

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

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!

source:php.cn
Statement of this Website
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
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template