2009-07-01

db2 delete table

Example 1: From the table DSN8910.EMP delete the row on which the cursor C1 is currently positioned.
  EXEC SQL DELETE FROM DSN8910.EMP WHERE CURRENT OF C1;
Example 2: From the table DSN8910.EMP, delete all rows for departments E11 and D21.
  EXEC SQL DELETE FROM DSN8910.EMP     WHERE WORKDEPT = 'E11' OR WORKDEPT = 'D21';
Example 3: From employee table X, delete the employee who has the most absences.
  EXEC SQL DELETE FROM EMP X     WHERE ABSENT = (SELECT MAX(ABSENT) FROM EMP Y     WHERE X.WORKDEPT = Y.WORKDEPT);
Example 4: Assuming that cursor CS1 is positioned on a rowset consisting of 10 rows of table T1, delete all 10 rows in the rowset.
EXEC SQL DELETE FROM T1 WHERE CURRENT OF CS1; 
Example 5: Assuming cursor CS1 is positioned on a rowset consisting of 10 rows of table T1, delete the fourth row of the rowset.
EXEC SQL DELETE FROM T1 WHERE CURRENT OF CS1 FOR ROW 4 OF ROWSET;


邀請大家來參加派對吧! 邀請大家來參加派對吧!

0 留言: