DELETE

You can delete rows from a table only if you created the table or are specifically authorized to do so. You can delete information from a table by row. Individual fields in a row or complete columns of information cannot be deleted.

The DELETE statement consists of two parts:

DELETE FROM
The table from which rows are to be deleted.
WHERE
The rows to be deleted.

If DELETE is entered with no WHERE clause specified, all rows of the table are deleted. The table still exists, but it no longer contains any rows.

The following statement deletes employee number 140 from the table PERS.

DELETE FROM PERS
WHERE ID = 140

In this example, ID, rather than employee name, is used to avoid deleting more rows than anticipated, because there could be more than one employee with the same name.

You can delete more than one row with one DELETE statement. Include a condition to show which rows to delete. The next example deletes everyone in Department 10:

DELETE FROM PERS
WHERE DEPT = 10

For information about authorization, see GRANT.

[ Previous Page | Next Page | Contents | Index ]