Qhov txawv ntawm Kev Rho Tawm thiab Tso

Qhov txawv ntawm Kev Rho Tawm thiab Tso
Qhov txawv ntawm Kev Rho Tawm thiab Tso

Video: Qhov txawv ntawm Kev Rho Tawm thiab Tso

Video: Qhov txawv ntawm Kev Rho Tawm thiab Tso
Video: Qhov Tseeb Xwm Kab Los Yej - Dab Vaj Dab Tsev Part 5 2024, Kaum ib hlis
Anonim

Delete vs Drop

Ob qho Delete thiab Drop commands yog SQL (Structured Query Language) cov lus, thiab lawv tau siv nyob rau hauv rooj plaub ntawm tshem tawm cov ntaub ntawv los ntawm ib tug database. Rho tawm yog DML (Data Manipulation Language) hais kom ua. Nws deletes ib co los yog tag nrho cov ntaub ntawv los ntawm ib lub rooj raws li tus mob uas tus neeg siv tau teev tseg. Rho tawm nqe lus tshem tawm tsuas yog cov ntaub ntawv khaws tseg hauv lub rooj, tab sis cov qauv rooj nthuav qhia tib yam hauv cov ntaub ntawv. Drop command yog DDL (Data Definition Language) nqe lus, thiab nws ua nyob rau hauv ib txoj kev sib txawv los ntawm Delete hais kom ua. Nws tsis yog cov lus qhia raws li kev cai, yog li tshem tawm tag nrho cov ntaub ntawv los ntawm lub rooj, thiab nws tshem tawm cov qauv ntawm lub rooj thiab tag nrho cov ntaub ntawv xa mus rau lub rooj mus tas li los ntawm cov ntaub ntawv.

Delete lus

Raws li tau hais los saum toj no, Rho tawm cov lus tshem tawm cov ntaub ntawv los ntawm lub rooj raws li cov xwm txheej tau muab, thiab Cov Lus Qhia Qhov twg yog siv nrog Delete los qhia qhov yuav tsum tau ua. Yog hais tias qhov twg clause tsis tau teev nrog Delete, tag nrho cov ntaub ntawv rooj yuav raug tshem tawm ntawm lub rooj. Txawm li cas los xij, hauv kev ua haujlwm Delete, cov qauv rooj uas twb muaj lawm tseem zoo ib yam. Yog li ntawd, tus neeg siv tsis tas yuav txhais lub rooj qauv yog tias nws xav rov siv lub rooj dua. Raws li Rho tawm yog DML hais kom ua, nws tsis ua kom tiav tom qab ua tiav. Yog li, qhov no tuaj yeem dov rov qab txhawm rau txhawm rau rov ua haujlwm dhau los. Txwv tsis pub, daim ntawv cog lus yuav tsum raug hu ua kom hloov pauv mus tas li. Thaum ua tiav daim ntawv Delete, nws sau ib qho kev nkag rau hauv cov ntawv teev npe rau txhua kab deletion. Yog li, qhov no cuam tshuam rau kev ua haujlwm qeeb. Ib yam nkaus, nws tsis deallocate qhov chaw siv tom qab ua tiav.

Ua raws yog cov lus qhia rau Tshem tawm nqe lus.

DELETE NTAWM

or

DELETE NTAWM NO

Txhob nqe lus

Tshaj nqe lus tshem tawm tsis yog tsuas yog tag nrho cov ntaub ntawv teev tseg los ntawm cov ntaub ntawv tsis muaj xwm txheej, tab sis nws tseem tshem tawm cov qauv ntawm lub rooj, kev txwv tsis pub muaj kev ncaj ncees, kev ntsuas, thiab nkag mus rau cov cai ntawm cov lus cuam tshuam los ntawm cov ntaub ntawv mus tas li. Yog li, tag nrho cov kev sib raug zoo rau lwm lub rooj kuj tsis muaj nyob, thiab cov ntaub ntawv hais txog lub rooj raug tshem tawm ntawm cov ntaub ntawv phau ntawv txhais lus. Yog li, yog tias tus neeg siv xav rov siv lub rooj nws yuav tsum tau txhais lub rooj qauv thiab tag nrho lwm cov ntaub ntawv xa mus rau lub rooj dua. Drop yog DDL hais kom ua thiab tom qab ua tiav cov lus txib, nws tsis tuaj yeem rov qab rov qab dua, vim tias Drop hais kom siv qhov kev cog lus pib. Yog li ntawd, tus neeg siv yuav tsum tau ceev faj heev hauv kev siv cov lus txib no. Cov lus tso tseg tsis tuaj yeem siv rau ntawm cov rooj ua haujlwm, thiab nws kuj tsis tuaj yeem siv rau cov ntxhuav uas muaj cov ntsiab lus txawv teb chaws.

Drop hais kom siv tsis yog rau SQL ntxhuav xwb, tab sis kuj rau databases, views thiab kab lus, thiab tag nrho cov ntaub ntawv khaws cia hauv cov khoom no ploj mus ib txhis nrog rau cov khoom.

Ua raws li yog cov lus qhia raug rau kev tso tseg.

TAB TAB

Dab tsi yog qhov sib txawv ntawm Rho thiab Tso?

1. Rho tawm thiab tso cov lus txib tshem tawm cov ntaub ntawv ntawm cov ntaub ntawv.

2. Tab sis Rho tawm nqe lus ua qhov kev tshem tawm raws li kev tshem tawm, whereas Drop command deletes tag nrho cov ntaub ntawv nyob rau hauv lub rooj.

3. Tsis tas li ntawd, Rho tawm cov lus tshem tawm tsuas yog cov kab hauv lub rooj thiab nws khaws lub rooj qauv zoo ib yam, whereas, Drop command tshem tawm tag nrho cov ntaub ntawv hauv lub rooj thiab lub rooj qauv, thiab nws tshem tawm tag nrho lwm cov ntaub ntawv los ntawm database.

4. Rho tawm yog DML nqe lus, hos Drop yog DDL hais kom ua. Yog li, Rho tawm kev ua haujlwm tuaj yeem muab dov rov qab thiab nws tsis pib ua haujlwm, thaum lub sijhawm ua haujlwm poob tsis tuaj yeem thim rov qab txhua txoj hauv kev raws li nws yog daim ntawv cog lus pib.

5. Kev hais kom poob tsis tuaj yeem siv rau ntawm cov ntxhuav uas tau hais los ntawm cov kev txwv tseem ceeb txawv teb chaws, qhov Rho tawm cov lus txib tuaj yeem siv los ntawm qhov ntawd.

6. Drop hais kom ua yuav tsum tau siv ua tib zoo nrog kev nkag siab zoo piv rau cov lus Delete hauv SQL daim ntawv thov.

Pom zoo: