MS Access的自定义主键 [英] Custom primary key for MS Access
问题描述
我是Microsoft Access的新手.我只是想知道如何使用创建自定义主键?例如 abc-123 格式?
I am new in microsoft access. I was just wondering on how can I use create a custom primary key? for example abc-123 format?
推荐答案
实际上,如果使用2010或更高版本,则可以创建表触发器.表触发器可以使用某个字段(从中获取abc),然后使用其他字段(seq num),然后将值加+1.
Actually, you could create a table trigger if using 2010 or later. The table trigger could take some field (where you get the abc from) and then some other field (seq num) and then add + 1 to the value.
空中"代码如下所示:
表触发器的优点在于它在表(数据引擎)级别运行,因此,如果您使用ODBC,VB.net,FoxPro,Access等打开数据库,则PK密钥将始终为您自动生成.
The beauty of the table trigger is it runs at table (data engine) level, and thus if you open the database with ODBC, VB.net, FoxPro, Access etc. then the PK key will always auto generate for you.
这篇关于MS Access的自定义主键的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!