9

I have a table with 9 records in it but i want to insert a row in between of 5th and 6th record.

Renuka Ballal
  • 119
  • 1
  • 1
  • 2

2 Answers2

14

if you insist on

UPDATE mytable SET id = id + 1 where id > 5 ORDER BY id ASC

insert into mytable (id,..) values (6,...) 
Haim Evgi
  • 123,187
  • 45
  • 217
  • 223
3

In general, you don't insert a row at a specific location in a table.

If the row "order" is significant and has some special semantic, have the data reflect that with a proper column in the table structure.

Then use a SELECT ... ORDER BY ... to get rows sorted.

Marc Alff
  • 8,227
  • 33
  • 59