如果表具有主键,则在中间插入已从用户删除的行,并且它是自动增量 [英] Insert The Row In Middle Which Has Deleted From User If Table Has Primary Key ,and it Is Autoincrement

查看:51
本文介绍了如果表具有主键,则在中间插入已从用户删除的行,并且它是自动增量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的表格中我从中间删除了一行但现在我只想在那个地方插入它。

在我的表中有主键并且它是自动增量1
请帮帮我

先谢谢

In My Table I Have Delete One Row from The Middle But Now I Want To Insert It At That Place Only.
In My Table There is Primary Key And It Is Autoincrement By 1
Please Help Me
Thanks In Advance

推荐答案

你可能不应该尝试。您可以通过在执行此操作时禁用自动增量并重置信息,然后执行插入并将增量参数重新启用然后重新启用它来实现,但这确实不是一个好主意,因为它的优点是自动增量是它全部为您处理。如果你这样做,那么你最好在存储过程中执行它,因为SQL是一个多用户系统,如果有人在你自动增加禁用的同时尝试创建一个新记录,那么整个系统就会崩溃。



如果你想订购行,那么使用你自己的订购系统而不是让SQL处理它并指定你想要记录的位置 - 不要试图使用相同的系统两个不同且无关的目的。
You probably shouldn''t try. You can do it by disabling the auto-increment while you do it and resetting the info, then doing the insert and putting the increment parameters back then re-enabling it, but it really isn''t a good idea, because the advantage of an auto-increment is that it is all handled for you. If you do, then you had better do it in a stored procedure, because SQL is a multi-user system and if anyone tries to create a new record while you have auto-increment disabled you whole system will fall apart.

If you want to order the rows, then use your own ordering system instead of letting SQL handle it and specify where you want records - don''t try to use the same system for two different and unrelated purposes.


这篇关于如果表具有主键,则在中间插入已从用户删除的行,并且它是自动增量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆