How Short is Short Text? (1 Viewer)

isladogs

MVP / VIP
Local time
Today, 00:17
Joined
Jan 14, 2017
Messages
18,209
255 is the MAXIMUM but the length of individual fields is set in the table design.
In your case, it is set to 6 for that field but can easily be changed

OR possibly you have set an input mask that only allows 6 characters - if so, remove or edit it.
 
Last edited:

gemma-the-husky

Super Moderator
Staff member
Local time
Today, 00:17
Joined
Sep 12, 2006
Messages
15,641
I think Access must store short text differently to long text (meno)

A short text "text field" is stored with the other data fields in the record block for the entire record.

With a memo field, A pointer to the field is stored in the record, and the actual memo data is stored in a chain of linked record blocks I think.

That will by why you can't index a memo field, and so on.
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Yesterday, 18:17
Joined
Feb 28, 2001
Messages
27,147
Dave, this is an old memory from an old guy, but... from a time when MS wasn't playing their cards TOO close to their vest, I recall reading a discussion on this.

For all numeric fields of any type, the thing stored in the record is the number itself. So that covers all sizes of integer: BYTE, WORD, LONG, QUAD, CURRENCY (which is a typecast of OCTAWORD), and BOOLEAN (which is a typecast of BYTE); SINGLE, DOUBLE, and DATE (which is a typecast of DOUBLE). However, for text fields, the thing stored in the record is a descriptor structure. The structure contains four fields: Two BYTE fields encoded to identify the field (as type SCALAR + STRING), a WORD for size, and a LONG for the pointer address relative to the start of the database file. The pointer then points to the first free byte following the actual record, and you use the size and pointer fields to pick up the text. If you have more than one text field, the second string starts after the end of the maximum string for the first text field.

If you use a LONG TEXT field, again you get a descriptor - but this time the address portion of the descriptor does not point to the end of the related record. The LONG TEXT / MEMO field could be anywhere in the address space. I don't recall reading about the MEMO using linked blocks, but it would make sense.

And I'll repeat that it has been years since I read about this so my cob-webby memory might have a few loose strands here and there.
 
Last edited:

gemma-the-husky

Super Moderator
Staff member
Local time
Today, 00:17
Joined
Sep 12, 2006
Messages
15,641
OK.

I assumed that since Access has an absolute 4000 byte limit for records, which includes short text fields, but not long text fields, then access must be storing the short text values within the record block. Maybe it's more efficient to store the text elsewhere. I presume it still must be stored in 255 char blocks somehow, and a short text restricts you to a single block.

We don't have to know, do we?
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Yesterday, 18:17
Joined
Feb 28, 2001
Messages
27,147
For LONG TEXT, it IS more efficient to store stuff elsewhere. For SHORT TEXT, they keep everything together probably just to keep it from getting lost. And most of the time we really don't need to know. Just like we really don't need to know record storage order.
 

gemma-the-husky

Super Moderator
Staff member
Local time
Today, 00:17
Joined
Sep 12, 2006
Messages
15,641
For LONG TEXT, it IS more efficient to store stuff elsewhere. For SHORT TEXT, they keep everything together probably just to keep it from getting lost. And most of the time we really don't need to know. Just like we really don't need to know record storage order.

I didn't appreciate the way you described the storage of (short) text fields. I thought you were originally saying they were also stored off-record. Now I re-read it, you weren't, were you? You were saying the short text fields were stored with all the other data fields.
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Yesterday, 18:17
Joined
Feb 28, 2001
Messages
27,147
Yes. Take all of the numeric fields at their face value. They are stored in order of definition in the Table's Field Definition grid. But an 8 byte Descriptor is stored in the place of the SHORT TEXT and its 32-bit address field points to the first free byte (in the same 4Kb disk block) after the last field, so it is something like

Code:
BYTE  PART
0     START OF RECORD
0     LONG
4     LONG
8     WORD
10    DOUBLE
18    DESCRIPTOR #1 for SHORT TEXT (10)
26    DESCRIPTOR #2 for SHORT TEXT (80)
34    DOUBLE
42    YES/NO
43    YES/NO (last field)
44    reserved space for string #1 (which might not hold as many as 10 bytes)
54    reserved space for string #2 (which might not hold as many as 80 bytes)
134   END OF RECORD

Although I vaguely remember that it is possible that the strings are actually compressed AND the reserved space is ALSO compressed. If you edit a text field to make it longer or shorter, you rewrite the record to the corrected length, then remove the old record and thread in the new record. Which is yet another reason why you never know the actual order of record appearance in an active table.
 

Users who are viewing this thread

Top Bottom