Is it possible to insert a line in the middle of the table and move the id?

Table:

id | val -------- 1 | value 1 -------- 2 | value 2 -------- 3 | value 3 

After insertion (id 2, value 4):

 id | val -------- 1 | value 1 -------- 2 | value 4 -------- 3 | value 2 -------- 4 | value 3 
  • It depends on how much data is available and what methods are available. You need more specifics than and under what circumstances you want to do it. - Dmitry Gvozd
  • @ Dmitriy I can know the queries and I myself, I wonder if there is one specific request so as not to make sham bicycles - Rammsteinik
  • The possibility is, that is, only in the first for two operations, in the second, the id should not be an autoincrement, in the third - this is a very difficult operation since can change almost all the entries in the table and in the fourth, the most important thing is that you almost never need to do this in relational databases. And if you still really want to write something for what it is, there surely are more practical solutions to the problem than id renumbering - Mike
  • @Mike autoincrement, of course, did not think that id renumbering was such a critical and undesirable task - Rammsteinik
  • The field autoincrement cannot be changed at all. It is necessary to lead id by other methods. Here you insert the second entry, and after it there are 10k more, for example. What do you think how much time will go change 9998 records? In general, IDs should never be changed if possible, so they are IDs. Suddenly, you have another link to this table - Mike

0