条形码字段长度 [英] Barcode field length

查看:98
本文介绍了条形码字段长度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在写一些出勤软件.每个成员都将拥有一个带有条形码的ID卡,他们将使用该ID登录事件.条码字段应在我的数据库中保留多长时间?我想接受Code 39和Code 128条码.我知道这些是可变长度代码,那么我应该将最大长度设置为什么?

I'm writing some attendance software. Each member will have an ID card with a barcode which they will use to sign in to events. How long should the barcode field be in my database? I'd like to accept Code 39 and Code 128 barcodes. I know these are variable length codes, so what should I set the max length to?

谢谢!

我的客户将使用各种第三方条形码打印工具.

My clients will be using a variety of third-party barcode printing tools.

推荐答案

代码128可以处理128个ASCII字符,因此将最大长度设置为128(或更大,这没关系).

Code 128 can do 128 ASCII characters so set the max length to 128 (or higher, it doesn't really matter).

让我澄清一下最后的陈述.可变文本字段每个字符将使用1个字节(对于Unicode类型字段,将使用多个字节,但现在让我们忽略它们)加上一些开销.根据数据库的不同,该开销可能只有1-4个字节,或者多达16个或更多.

Let me clarify that last statement. Variable text fields will use 1 byte per character (or more for Unicode type fields but let's ignore those for now) plus some overhead. That overhead might be as little as 1-4 bytes or as much as 16 or more depending on the database.

但是要点是,如果您在VARCHAR(128)字段或VARCHAR(1000)字段中存储100个字符,它仍然会使用完全相同的空间.

But the point is that if you store 100 characters in a VARCHAR(128) field or a VARCHAR(1000) field it still uses the exact same amount of space.

您遇到的唯一问题是行数限制.这也取决于数据库.例如,在某些情况下,整行最多只能容纳64K,因此所有大小的总和不能超过该大小.除此之外,没关系.

The only issue you run into is row limits. This too is database dependent. On some for example the entire row can only take up to 64K in size so the sum of all sizes can't exceed that. Other than that it doesn't matter.

这篇关于条形码字段长度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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