Deleting rows of information from the database is very straightforward with the DELETE statement.
Here is the syntax:
DELETE FROM
WHERE ;
Again, the WHERE clause provides the same flexible and powerful mechanisms for identifying those
rows to be deleted.
To remove Mary Poppins from the database, this DELETE statement will work:
DELETE FROM Student WHERE Sname = 'Mary Poppins';
To remove all rows from a table, one simply omits the WHERE clause??”be careful not to do so by accident!
Remember also that to remove the table itself from the database, one must use the DROP statement.
CHAP. 8] DATABASE 155
Having discussed the DML statements, we will return to the SELECT statement to discuss correlated
subqueries. When the evaluation of a subquery references some attribute in the outer query, the nested or subquery
is described as a correlated subquery.
To imagine the workings of a correlated subquery, imagine that the subquery is executed for each row in
the outer query. The outer query must work through all the rows of a table, and the inner query must have
information from the row being referenced in order to complete its work.
For example, suppose one wants to know if there are any dormitories in the database that have no students
assigned to them.
Pages:
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429