phpMyadmin中重新设置表自动增量的触发器
我有一个数据库,tvguide,这些是值:
id bigint 255 UNSIGNED AUTO_INCREMENT
programme varchar 255
default value (which is from another table
with list of programs, the only linked field that
is shared with other table):<b><a href="gossipgirl.php">Gossip Girl</a></b>
channel varchar 255
airdate DATETIME - actual airtime
displayair DATETIME (rounded-up datetime, e.g. programme that airs 1.59pm
would be shown as 2.00pm, or 6.08pm as 6.10pm)
expiration DATETIME - when program finishes
episode VARCHAR 255 NULL - has null option if episode unknown
series VARCHAR 255
epno VARCHAR 255 - episode number
setreminder VARCHAR255 (shows "set reminder", sends email to user, but that's
another thing to work on).
我想在我的数据库中插入一个触发器,以便如果删除一条记录,ID 自动增量会自动重新设置?
关于如何实现这一目标有什么想法吗?到目前为止,我已经手动完成了此操作,但我正在考虑删除记录时可以使用 phpMyadmin 做什么。
顺便说一句,我制作了该表的副本以用于备份目的。
谢谢
I have a database, tvguide and these are the values:
id bigint 255 UNSIGNED AUTO_INCREMENT
programme varchar 255
default value (which is from another table
with list of programs, the only linked field that
is shared with other table):<b><a href="gossipgirl.php">Gossip Girl</a></b>
channel varchar 255
airdate DATETIME - actual airtime
displayair DATETIME (rounded-up datetime, e.g. programme that airs 1.59pm
would be shown as 2.00pm, or 6.08pm as 6.10pm)
expiration DATETIME - when program finishes
episode VARCHAR 255 NULL - has null option if episode unknown
series VARCHAR 255
epno VARCHAR 255 - episode number
setreminder VARCHAR255 (shows "set reminder", sends email to user, but that's
another thing to work on).
I want to insert a trigger into my database so that if a record is deleted, the ID auto-increment re-sets itself automatically?
Any ideas on how to accomplish this? I've done it manually so far but am looking at seeing what I can do with phpMyadmin when I delete the record.
BTW I made a copy of the table for backup purposes.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我同意whitstone86的评论,你可以“让它成长”。
话虽如此,要随时更改
AUTO_INCRMENT
,您只需运行ALTER TABLE
即可。一些伪代码...
对于生产,竞争条件可能是一个问题。然而,如果只是你在 phpmyadmin 中闲逛,这应该足够了。
I agree with whitstone86's comment that you can just "let it grow".
Having said that, to change the
AUTO_INCREMENT
at any time, you can just run anALTER TABLE
.Some pseudo code...
For production, race conditions might be an issue. However, if it's just you puttering around in phpmyadmin, this should suffice.
这是一个相当危险的想法。
让它成长,它不会发生:250000000011 在你的程序中使用与 250000000012 相同的位置
表,特别是因为它是一个 bigint (8 字节)。
否则
This is a rather dangerous idea.
Let it grow, it doesn't take place: 250000000011 use the same place as 250000000012 in your
table, especially since it's a bigint (8 bytes).
Otherwise