如何制作唯一的身份证号码? [英] how to make a unique ID number?

查看:280
本文介绍了如何制作唯一的身份证号码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个名为ID的表字段,ID为1,2,3(自动实现)

另一个表字段名为DocType,其数据为DOc1 Doc2 Doc3,所以这就是问题所在:



我保存了Doc1并创建了一个ID,即与Doc2和Doc3相同

然后我使用ID 4保存了另一个数据,但数据的名称是Doc1



现在,当我使用ID 1检索数据时,它检索Doc1,与Doc2和Doc3,但当我检索到ID 4时,它会检索Doc1(我保存的第一个Doc1,我有一个数据和时间,所以我知道哪个是第一个)



我需要知道如何创建一个唯一的ID号,所以即使我用相同的名称保存它,但我知道哪个是最先出现的,也是我最近保存的。

I have a Table field that is name ID and the ID''s are 1,2,3 (Auto Implemented)
another table field is named DocType and its data DOc1 Doc2 Doc3, so here''s the problem:

I saved Doc1 and Creates an ID i.e. 1, same as for Doc2 and Doc3
but then I saved another data with an ID 4, but the data''s name is Doc1

now, when I retrieve a data using ID 1 it Retrieves Doc1, same as for Doc2 and Doc3 but when I retrieve ID 4 it retrieves the Doc1 (the First Doc1 I saved, i has a data and time so i know which was first)

I need to know how to create a unique ID number so even if I save it with the same name but with a different date i know which came first and which I saved recently.

推荐答案

使用将充当唯一索引的主键,并在您创建索引的字段上自动创建索引。你发布你的整个结构,以便我可以用代码更详细地说明它。但简单的逻辑是在字段上创建索引或创建主键约束,以便它甚至不允许用户插入重复项。



Rgds,

Nitesh ..
Use primary key which will act as unique index and it automatically created indexes on the field where you are creating index . Its you post your whole structure so that i can elaborate it more with codes .. But simple logic is to create either indexes on fields or else creating primary key constraint so that it wont even allow the user to insert duplicates ..

Rgds,
Nitesh..


这篇关于如何制作唯一的身份证号码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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