How do I delete either the first or last set of rows in a dynamic fashion

后端 未结 3 1133
太阳男子
太阳男子 2021-01-01 13:30

I would like to delete the first 100 rows or the last 100 rows in a certain table (ordered by the primary key).

Note: Lots of data is being spooled into this table.<

3条回答
  •  旧时难觅i
    2021-01-01 14:24

    for first 100,

    DELETE FROM table ORDER BY  ASC limit 100
    

    and for last 100,

    DELETE FROM table ORDER BY  DESC limit 100
    

提交回复
热议问题