Home > Database > SQL > body text

Statement to delete rows in sql

下次还敢
Release: 2024-05-07 06:12:14
Original
1217 people have browsed it

In SQL, rows are deleted through the DELETE statement. The syntax is DELETE FROM table_name WHERE condition. In the parameters, table_name refers to the target table, and condition is an optional condition, specifying the rows to be deleted. If omitted, all rows will be deleted. For example: delete the row named "John" DELETE FROM customers WHERE name = 'John'; delete the amount greater than $100 row DELETE FROM orders WHERE amount > 100.

Statement to delete rows in sql

Statements to delete rows in SQL

How to delete rows

## The #DELETE statement is used to delete rows from a table.

Syntax

<code class="sql">DELETE FROM table_name
WHERE condition;</code>
Copy after login

Parameters

  • table_name: The table to delete rows from name.
  • condition: Optional condition that specifies which rows to delete. If you do not specify a condition, all rows in the table will be deleted.

Example

Delete all rows with the name "John" in the

customers table:

<code class="sql">DELETE FROM customers
WHERE name = 'John';</code>
Copy after login
Delete

orders All rows in the table with amounts greater than $100:

<code class="sql">DELETE FROM orders
WHERE amount > 100;</code>
Copy after login

Note

    Once deleted, the data will be permanently lost, so please Back up your data before executing the DELETE statement.
  • If you do not specify a condition, all rows in the table will be deleted, including rows with foreign key relationships.
  • To improve performance, consider using an index to speed up finding and deleting specified rows.

The above is the detailed content of Statement to delete rows 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