I have a mySql database that contains a table have which four fields Id(primary key & auto increment), Node, Distance,pressure.

我有一个mySql数据库,其中包含一个表有四个字段Id(主键和自动增量),节点,距离,压力。

ID      Node    Distance    Pressure 
001     15       320        45
002     16       420        41
003     17       520        45
.
.
.
.
10000    256     1245        1542

The problem is that, if you want to insert a new record then the New record's ID become 10001 but I want to insert a New Record Between two records. for ex: i need to insert a new record between 001 and 002 here is the problem. I need the New record's ID as 002. currently I am solving this problem by updating tables .But it is not feasible for large number of records.

问题是,如果要插入新记录,则新记录的ID将变为10001,但我想在两个记录之间插入新记录。例如:我需要在001和002之间插入一条新记录,这是问题所在。我需要新记录的ID为002.目前我通过更新表来解决这个问题。但是对于大量记录来说这是不可行的。

2 个解决方案

#1


1

I don't think you can Insert a Row if ID is an auto-increment equivalent to Identity column, Considering SQL Server

如果ID是一个等同于Identity列的自动增量,我认为你不能插入一行,考虑SQL Server

Update: Also in Mysql

更新:也在Mysql中

Auto-Increment in MySQL we can't insert Row if ID is and auto-increment.

MySQL中的自动递增如果ID为自动递增,则无法插入行。

Thanks Mahmoud Gamal

感谢Mahmoud Gamal

更多相关文章

  1. 尝试使用PHP和MySQL获取节点的路径
  2. 急啊,在线等!!mysql 如何实现增量备份
  3. 如何从一个节点生成exe文件。js应用?
  4. 前端笔记之JavaScript(十)深入JavaScript节点&DOM&事件
  5. js的html元素的父节点,子节点
  6. 不使用chokidar更新所需的节点/快速模块?
  7. 当尝试安装节点时,会得到一个“DLL”错误。js在Windows 7上
  8. contains和compareDocumentPosition 方法来确定是否HTML节点间的
  9. 如何访问远程节点。浏览器中的js应用程序,而不是本地主机

随机推荐

  1. Android(安卓)View requires API level 1
  2. Android开发实现二级联动下拉列表
  3. android:shrinkColumns的用法 (2011-04-2
  4. android OkHttp3
  5. activity
  6. xposed框架的检测和反制
  7. Android编程简单设置ListView分割线的方
  8. AndroidStudio 开发自我小结(1)
  9. Android属性大全之shape
  10. Android启动页上下白屏适配