DELETE

DELETE bayonoti jadvaldagi mavjud yozuvlarni o'chirish uchun ishlatiladi.

SU

SQL DELETE Bayonoti Nima?

DELETE bayonoti jadvaldagi mavjud yozuvlarni o'chirish uchun ishlatiladi.

DELETE Sintaksisi

DELETE FROM table_name WHERE condition;

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:

CustomerIDCustomerNameContactNameAddressCityPostalCodeCountry
1Alfreds FutterkisteMaria AndersObere Str. 57Berlin12209Germany
2Ana Trujillo Emparedados y heladosAna TrujilloAvda. de la Constitución 2222México D.F.05021Mexico
3Antonio Moreno TaqueríaAntonio MorenoMataderos 2312México D.F.05023Mexico
4Around the HornThomas Hardy120 Hanover Sq.LondonWA1 1DPUK
5Berglunds snabbköpChristina BerglundBerguvsvägen 8LuleåS-958 22Sweden

SQL DELETE Misoli

Quyidagi SQL bayonoti "Customers" jadvalidan "Alfreds Futterkiste" mijozini o'chiradi:

Misol O'zingizning SQL serveringizni oling

DELETE FROM Customers WHERE CustomerName='Alfreds Futterkiste';

"Customers" jadvalidan olingan tanlov endi quyidagi ko'rinishda bo'ladi:

CustomerIDCustomerNameContactNameAddressCityPostalCodeCountry
2Ana Trujillo Emparedados y heladosAna TrujilloAvda. de la Constitución 2222México D.F.05021Mexico
3Antonio Moreno TaqueríaAntonio MorenoMataderos 2312México D.F.05023Mexico
4Around the HornThomas Hardy120 Hanover Sq.LondonWA1 1DPUK
5Berglunds snabbköpChristina BerglundBerguvsvägen 8LuleåS-958 22Sweden

Barcha Yozuvlarni O'chirish

Jadvaldagi barcha qatorlarni o'chirish mumkin, lekin jadvalning o'zi o'chirilmaydi. Bu, jadval tuzilishi, atributlari va indekslari saqlanib qoladi:

DELETE FROM table_name;

Quyidagi SQL bayonoti "Customers" jadvalidan barcha qatorlarni, jadvalni o'chirmasdan, o'chiradi:

Misol

DELETE FROM Customers;

Jadvalni O'chirish

Jadvalni to'liq o'chirish uchun DROP TABLE bayonotidan foydalaning:

Misol "Customers" jadvalini o'chirish:

DROP TABLE Customers;

Ushbu sahifada

Xato haqida xabar berish