How do I LIMIT the number of rows in a DELETE with DB2?

后端 未结 9 581
醉梦人生
醉梦人生 2021-01-11 17:09

I want to add a security on a sensitive table when I delete lines with an SQL request on a DB2 table.

I want to mimic the way MySQL allows you to limit the numbers o

9条回答
  •  攒了一身酷
    2021-01-11 18:04

    DELETE                                      
    FROM Bibl/File                             
    WHERE RRN(File) =  (                        
                        SELECT min(RRN(File))   
                        FROM Bibl/File         
                        WHERE Fld1 = 'xx'     
                       )   
    

    The RRN function is to AS400/iSeries/PowerSystem alone. In other environments there are other functions for the relative record number.

    This makes it possible to erase a record of several identical even without UNIQUE key. It can also be used to update with minor changes.

    works like the LIMIT but with DELETE and / or UPDATE.

    It only works on SQL DB2 in other settings should be changed by RRN function to return the column number

提交回复
热议问题