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

asked 29 Mar, 09:08

Franz_Stf's gravatar image

accept rate: 0%

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.

permanent link

answered 29 Mar, 10:10

Volker%20Barth's gravatar image

Volker Barth
accept rate: 32%

edited 29 Mar, 10:12

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

(29 Apr, 03:23) Martin
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:


question asked: 29 Mar, 09:08

question was seen: 125 times

last updated: 29 Apr, 03:23