Collection Contents Index Making changes permanent Validity checking pdf/chap15.pdf

First Guide to SQL Anywhere Studio
   PART 3. Basic SQL
     CHAPTER 15. Updating the Database       

Deleting rows


Sometimes you will want to remove rows from a table. Suppose Rodrigo Guevara (employee ID 249) leaves the company. The following statement deletes Rodrigo Guevara from the employee table.

DELETE
FROM employee
WHERE emp_id = 249

Example 

You can delete more than one row with one command. For example, the following statement would delete all employees who had a termination date that is not NULL from the employee table.

DELETE
FROM employee
WHERE termination_date IS NOT NULL

This example would not remove any employees from the database as the termination_date column is NULL for all employees.

With UPDATE and DELETE, the search condition can be as complicated as you need. For example, if the employee table is being reorganized, the following statement removes from the employee table all male employees hired between March 3, 1989 and March 3, 1990.

DELETE
FROM employee
WHERE sex = 'm'
    AND start_date between '1988-03-03'
    AND '1989-03-03'

Since you have made changes to the database that you do not want to keep, you should undo the changes as follows:

ROLLBACK

Collection Contents Index Making changes permanent Validity checking pdf/chap15.pdf