You are viewing limited content. For full access, please sign in.

Question

Question

Is a metadata text field varchar or char?

asked on December 3, 2019

If I define a metadata text field to be 2,000 characters will that create a char(2000) field to be stored in the database or will it be varchar(2000)?

I checked the help file for metadata fields but all I found was:

Field Types -Before creating or modifying a field, you should be familiar with available field types. 

Text - The Text type is the most permissive type of field.  Any text can be assigned to it.  However, you can optionally constrain a text field to restrict the type or format of information stored in it.
 

0 0

Replies

replied on December 3, 2019

See system limits. Text fields can store up to 4000 characters.

0 0
replied on December 3, 2019

"Maximum field length 4000 in characters for list and string types"

This still doesn't answer the question as to which way it is stored.

I don't want to define a text field to be 2000 characters if it stores 2000 bytes with every record whether there is data in it or not.  

I am creating a text field called "comments" and I would like to allow a large number of characters for the occasional Shakespeare, but most of the time it would not need to be that big.

That means that most of the time I would be wasting space if behind the scenes the field was set to char(2000) vs. varchar(2000).

So which way is it stored?

0 0
replied on December 3, 2019

In the database, metadata fields have multiple columns they can be stored in depending on the length and type. The "main" columns are as follows:

  • nvarchar(4000)
  • nvarchar(100)
  • decimal(18,5)
  • datetime

For text fields, anything 100 or less seems to be stored in both the 4000 and 100 columns, but if it is longer than 100 that column will be NULL and it will only be in the 4000 column.

Anything set as a numeric or date/time would only be stored in the corresponding column.

Dynamic column creation would be a nightmare, so the only practical solution is to include a minimal number of columns that can still accommodate all of the possible field variations.

1 0
replied on December 3, 2019

Thank you, that is what I wanted to know - if it is stored as nvarchar then I can define my text field as 2000 characters without worrying about wasting space.

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.