Is it possible to insert a new row at top of MySQL table?

后端 未结 5 849
别跟我提以往
别跟我提以往 2020-12-10 05:43

All rows in MySQL tables are being inserted like this:

1
2
3

Is there any way how to insert new row at a top of table so that table looks l

5条回答
  •  不思量自难忘°
    2020-12-10 06:23

    Maybe if you add the id 'by hand', and give it a negative value, but i (and probably nobody) would recommend you to do that:

    1. Regular insert, e.g.

      insert into t values (...);

    2. Update with set, e.g.

      update t set id = -id where id = last_insert_id();

提交回复
热议问题