SQL DELETE Statement
- DELETE permanently removes records from a table.
- DELETE can delete one or more records in a table.
- Use the WHERE clause to DELETE only specific records.
The SQL DELETE syntax
The general syntax is:
- DELETE table-name
To delete specific records append a WHERE clause:
- DELETE table-name WHERE condition
SQL DELETE Examples
1) Normal Delete or without Where Clause delete
mysql> delete
from person;
Query OK, 4 rows
affected (0.01 sec)
mysql> select
*from person;
Empty set (0.00 sec)
2) Delete With Where Clause
mysql> delete
from person where sno='4';
Query OK, 1 row
affected (0.01 sec)
mysql> select
*from person;
+-----+--------+------+----------------------+------+------------+
| sno | name | age
| email | sex | phone |
+-----+--------+------+----------------------+------+------------+
| 1 | subham |
25 | NULL | M | NULL |
| 2 | nunu |
25 | NULL | M | NULL |
| 3 | chayan |
25 | NULL | M | NULL |
+-----+--------+------+----------------------+------+------------+
4 rows in set (0.01
sec)
Comments
Post a Comment