且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在sql中添加16位自动增量字段?

更新时间:2021-09-16 01:15:33

我不建议这样做(尝试在你的主要领域放置几个信息)。



为什么你不使用简单的整数主键,并将你的密码/等级存储在另一列?



主键的目标是识别没有歧义的唯一记录;试图在其中添加更多信息会给你带来更多问题而不是解决。



另外,主键被编入索引;如果你使用一个大值作为主键,你将因索引维护而遭受巨大的性能损失。



所以我不打算给出一个解决方案以你分析它的方式解决问题。您应该检查您的设计并坚持有关数据库设计的众所周知的良好实践。
I don''t recommend to do that (trying to put several informations in your primary field).

Why don''t you use a simple integer primary key, and store your pincode/rank in another column ?

The goal of a primary key is to identify a unique record without ambiguity ; trying to put more informations in it will give you more problems than it will solve.

Plus, primary keys are indexed ; if you use a large value as a primary key, you will suffer huge performance losses due to maintenance of index.

So I''m not going to give a solution to your problem the way you have analyzed it. You should review your design and stick to well-known good practices regarding database design.