Home> Database> SQL> body text

How to write modification statements in sql

下次还敢
Release: 2024-05-07 06:15:30
Original
1095 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:

UPDATE <表名> SET <列名> = <新值>, ... WHERE <条件>;
Copy after login

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

UPDATE employees SET salary = 10000 WHERE name = "John Doe";
Copy after login

DELETE statement

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

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

For example, to delete an employee named "John Doe" from theemployeestable:

DELETE FROM employees WHERE name = "John Doe";
Copy after login

INSERT INTO statement

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

INSERT INTO <表名> (<列名1>, <列名2>, ...) VALUES (<值1>, <值2>, ...);
Copy after login

For example, insert a new employee "Jane Smith" in theemployeestable:

INSERT INTO employees (name, salary) VALUES ("Jane Smith", 8000);
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 Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!