Barcode field length

孤人 提交于 2019-12-04 03:52:10

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

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.

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.

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.

guest

No constraints on Code 128 in theory, but for example, one of applied specifications (GS1) sets practical limits:

GS1-128 has a maximum of 48 characters (excluding special characters) OR a maximum of 6.5" (including quiet area). The limit is based upon whichever comes first.

Source: GS1-128 Symbol Specifications

These formats can easily encode plenty of digits, surely more than you need for a unique ID. So isn't the question merely, how long are your IDs? Is 10 digits plenty? then 10 characters. Or if they're numeric IDs, you shouldn't even store as a string of characters. Use a numeric SQL type.

Code 39 is restricted to 43 characters. In Full ASCII Code 39 Symbols 0-9, A-Z, ".", "-" and space are the same as their representations in Code 39.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!