Stores text values that vary in length. However, unlike with characters, it optimizes database storage.
Specifies the possible maximum length that is predetermined by the DBMS you are using. If the length assigned to the attribute is greater than what is actually supported by the DBMS then the DBMS' maximum will be used.
Is the average length. This is used to optimize disk accesses in some DBMSs (particularly in the iSeries). The idea is that when the value of a varchar attribute is less than or equal to N, as N characters are stored (filled with blanks) in the file's record, only one disk access is required to read or store its value. If the value of the varchar attribute is greater than N, the first N are stored in the file's record and the rest are placed in an overflow area for which an additional access is required to ensure that the value is read as a whole.
The following table illustrates the properties used to define the Data Type:
All functions and operators can be applied to this character data type.
The varchar data type is equivalent to character data types in all senses except in the way that they are stored in databases.
For those DBMSs that do not support this data type, it will be created as Character.
The following table illustrates the maximum length tolerated by each DBMS, with the last column showing the conversion done by GeneXus:
||Max Length (M)
||Avg. Length (N)
||Varchar(M) or Varchar2(M) 3
|DB2 Universal Database
||0 to Max length
|DB2 UDB for iSeries / iSeries Native
||0 to Max length
1 If a column is defined in GX as Varchar(x), where x >= 255 (or 254, if it is part of an index), the field will be defined as lvarchar in the database. Besides, in this case, the average length is ignored.
2 The DBMS does not support strings that vary in length (except for Long Varchar). Strings are implemented with fixed lengths. That is, a character is generated taking the length from Max Length.
3 Varchar or Varchar2; depending on the Declare Varchar as Varchar 2 Data Store(Oracle) property.
4 Before Mysql 5.0.3.
5 In Mysql 5.0.3 and later versions.
6 16000 if Enable national language support property is Yes
Attributes and variables assigned to these data types appear in reports/selectors as V (for example: V(40)). Although this data type makes use of the auto-resize facility in forms and print blocks, they can never display anything over 255 characters.
DateTime data type
LongVarChar data type
Data types list