SQL Delete Statement
SQL Delete Syntax
DELETE
FROM table_name WHERE some_column=some_value
|
SQL DELETE EXAMPLE
“Persons” TABLE:
P_Id
|
LastName
|
FirstName
|
Address
|
City
|
1
|
Suhail
|
Osmani
|
Maharaj
Nagar
|
Sitapur
|
2
|
Maxwel
|
Tom
|
Biswan
|
Sitapur
|
3
|
Rahi
|
Ayon
|
Okhla
|
Delhi
|
4
|
Nyla
|
Johan
|
Bakken
2
|
Delhi
|
5
|
Thoria
|
Jakob
|
New
Road
|
Sitapur
|
We use the following SQL statement:
DELETE
FROM Persons WHERE LastName='Thoria' AND FirstName='Jakob'
|
P_Id
|
LastName
|
FirstName
|
Address
|
City
|
1
|
Suhail
|
Osmani
|
Maharaj
Nagar
|
Sitapur
|
2
|
Maxwel
|
Tom
|
Biswan
|
Sitapur
|
3
|
Rahi
|
Ayon
|
Okhla
|
Delhi
|
4
|
Nyla
|
Johan
|
Bakken
2
|
Delhi
|
Delete All Rows
It is possible to delete all rows in a table without deleting the table. This means that the table structure, attributes, and indexes will be intact:
DELETE
FROM table_name
|
SQL Delete Statement
Reviewed by Admin
on
04:18:00
Rating:
No comments: