Полезная информация

next up previous contents index
Next: Modifying Data with UPDATE Up: Five Basic SQL Commands Previous: WHERE Clause

Removing Data with DELETE

We know how to add data to the database. Now we learn how to remove it. Removal is quite simple. The DELETE command can quickly remove any or all rows from a table. The command DELETE FROM friends will delete all rows from the table friends. The query DELETE FROM friends WHERE age = 19 will remove only those rows that have an age column equal to 19.

Here is a good exercise. INSERT a row into the friends table, use SELECT to verify the row has been properly added, then use DELETE to remove the row. This combines the things learned in the previous sections. Figure [*] shows an example.

  
Figure: DELETE example
\begin{figure}\begin{list}{}{
\setlength{\rightmargin}{\leftmargin}
\raggedrigh...
...vert Allentown~~~~~~\vert PA~~~\vert~22
\par (3~rows)\end{list}\par
\end{figure}


Bruce Momjian
1999-11-21