DELETE
DELETE bayonoti jadvaldagi mavjud yozuvlarni o'chirish uchun ishlatiladi.
SQL DELETE Bayonoti Nima?
DELETE bayonoti jadvaldagi mavjud yozuvlarni o'chirish uchun ishlatiladi.
DELETE Sintaksisi
Eslatma: Jadvaldagi yozuvlarni o'chirishda ehtiyot bo'ling! DELETE bayonotidagi WHERE klauzasi qaysi yozuv(lar)ni o'chirilishi kerakligini belgilaydi. Agar WHERE klauzasini e'tiborsiz qoldirsangiz, jadvaldagi barcha yozuvlar o'chiriladi!
Demo Ma'lumotlar Bazasi
Quyida misollarda ishlatiladigan Customers jadvalidan tanlov keltirilgan:
CustomerID | CustomerName | ContactName | Address | City | PostalCode | Country |
---|---|---|---|---|---|---|
1 | Alfreds Futterkiste | Maria Anders | Obere Str. 57 | Berlin | 12209 | Germany |
2 | Ana Trujillo Emparedados y helados | Ana Trujillo | Avda. de la Constitución 2222 | México D.F. | 05021 | Mexico |
3 | Antonio Moreno Taquería | Antonio Moreno | Mataderos 2312 | México D.F. | 05023 | Mexico |
4 | Around the Horn | Thomas Hardy | 120 Hanover Sq. | London | WA1 1DP | UK |
5 | Berglunds snabbköp | Christina Berglund | Berguvsvägen 8 | Luleå | S-958 22 | Sweden |
SQL DELETE Misoli
Quyidagi SQL bayonoti "Customers" jadvalidan "Alfreds Futterkiste" mijozini o'chiradi:
Misol O'zingizning SQL serveringizni oling
"Customers" jadvalidan olingan tanlov endi quyidagi ko'rinishda bo'ladi:
CustomerID | CustomerName | ContactName | Address | City | PostalCode | Country |
---|---|---|---|---|---|---|
2 | Ana Trujillo Emparedados y helados | Ana Trujillo | Avda. de la Constitución 2222 | México D.F. | 05021 | Mexico |
3 | Antonio Moreno Taquería | Antonio Moreno | Mataderos 2312 | México D.F. | 05023 | Mexico |
4 | Around the Horn | Thomas Hardy | 120 Hanover Sq. | London | WA1 1DP | UK |
5 | Berglunds snabbköp | Christina Berglund | Berguvsvägen 8 | Luleå | S-958 22 | Sweden |
Barcha Yozuvlarni O'chirish
Jadvaldagi barcha qatorlarni o'chirish mumkin, lekin jadvalning o'zi o'chirilmaydi. Bu, jadval tuzilishi, atributlari va indekslari saqlanib qoladi:
Quyidagi SQL bayonoti "Customers" jadvalidan barcha qatorlarni, jadvalni o'chirmasdan, o'chiradi:
Misol
Jadvalni O'chirish
Jadvalni to'liq o'chirish uchun DROP TABLE bayonotidan foydalaning:
Misol "Customers" jadvalini o'chirish: