开发者

Is there a benefit to starting MySQL data base id at a large number?

So i noticed in a script i'm using that the id row in the database i have set up is started at 1728.

Is there any specific benefits in 开发者_如何学Cstarting a database id number at a large number or anything other then 1 ??


It looks somewhat cool for someone.

profile.php?id=1728 looks better than profile.php?id=1

But in your case, it's probably wrong SQL dump which had AUTO_INCREMENT 1728


Not that I'm aware of, although I've seen it used as a very simple security measure, which prevents the first user in a table of users (typically the admin / creator) from having user ID = 1.


No, there are no benefits. As long as the id is unique, it doesn't matter. Some developers prefer to start ids for some rows higher because it seems to look better in a url. For example, this url:

http://www.example.com/user/profile.php?id=142541

looks better than:

http://www.example.com/user/profile.php?id=1


I don't know of any real reason. Perhaps then people don't guess that your admin user ID is 1.

I have seen tables start with non-1 IDs when using auto-incrementing IDs. Every attempted insert will increment even if the insert fails. In your case the table may have incremented to 1728 while the script was being developed so the first "real" record was 1728.


We can only guess. There are no technical benefits as such. But there may be soft benefits. I can imagine that it's done with the intention of having some reserved IDs for old/previous backup .sql dumps or even default database entries.

I occasionally start IDs (if I really have to expose database-internal numbering in the UI) at larger numbers like 1000, so I get e.g. 4-digit numbers for all IDs. Not technical necessary, but may look more consistent.


@Jake Chapman, The reason behind it is that if one see

profile.php?id=1 or profile.php?id=2 ...

all these takes programmer's attention, and tricky programmer would like to play some hacking tricks because they know well what can be done to it.

Numbers likes

profile.php?id=1343 or profile.php?id=2543 ...

Some confusing and don't take attntion suddenly that is why.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜