Removing Rows Using the DELETE Statement


You use the DELETE statement to remove rows from a table. Generally, you should specify a WHERE clause that limits the rows that you wish to delete. If you don t, all the rows will be deleted.

The following DELETE statement removes the row from the customers table whose customer_id is 2:

  DELETE FROM customers   WHERE customer_id = 2;  1 row deleted. 

SQL*Plus confirms that one row has been deleted.

You can also use a subquery with a DELETE statement. This was covered in Chapter 6 in the section Writing a DELETE Statement Containing a Subquery.

Note  

If you ve been following along with the previous INSERT , UPDATE , and DELETE statements, roll them back using ROLLBACK . If you disconnected from the database before performing the rollback, don t worry: simply rerun the store_schema.sql script to re-create everything.




Oracle Database 10g SQL
Oracle Database 10g SQL (Osborne ORACLE Press Series)
ISBN: 0072229810
EAN: 2147483647
Year: 2004
Pages: 217

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net