Saturday, November 14, 2009

DELETE Statement

You can remove existing rows from a table by using the DELETE statement :
  • DELETE [FROM] table [WHERE condition];
Deleting Rows from a Table :
Specific rows are deleted if you specify the WHERE clause :
  • DELETE FROM dept WHERE dname = 'Finance';
All rows in the table are deleted if you omit the WHERE clause :
  • DELETE FROM copy_emp;
Deleting Rows Based on Another Table :
  • Use subqueries in DELETE statements to remove rows from a table based on values from another table :
  • DELETE FROM emp WHERE deptno = (SELECT deptno FROM dept WHERE dname =‘SALES’);

No comments:

Post a Comment

Followers