cancel
Showing results for 
Search instead for 
Did you mean: 

The best data type for a text field

1,534

Hi all, Which data type is best used for a text field (about 2 kbyte size) in an SQL Anywhere database? The length of the text field will be variable. Regards from Bavarian Franz

Accepted Solutions (1)

Accepted Solutions (1)

VolkerBarth
Contributor

See that question varchar vs. long varchar with a profound discussion on the consequences of "real long strings".

Besides that, SQL Anywhere does not distinguish CHAR from VARCHAR (in contrast, say to ASE or MS SQL Server, which treat CHAR as strings with a fixed length and blank-padding), so all strings are variable in length by design. Therefore from a database point of view, it doesn't matter if you use VARCHAR(20) or VARCHAR(20000) when your strings are all at most 20 characters long, the required space will be the same. (Of course, if you know strings are short because of business rules, it is IMHO helpful to limit the declared size, too.)

Of course, there's also the choice between unicode strings (aka NVARCHAR) vs. multi-byte strings.

MCMartin
Participant

for Multi Byte collations like UTF-8 the usage of varchar(20 char) is more intuitive as Chars are counted not Bytes.

Answers (0)