Variable Character Field

Why Trust Techopedia

What Does Variable Character Field Mean?

A variable character field (varchar) is a data type which can contain any type of data: numeric, characters, spaces or punctuation. Depending on the database, the data type is capable of storing values up to its maximum size. Variable character fields are mostly used to act as temporary variables and for string operations. They bring in much-needed versatility for data field types.

Advertisements

Techopedia Explains Variable Character Field

A variable character field can be defined either in the programming language or on the database level. A variable character field always has a declared maximum length and is usually initialized with the current length equal to zero. The current length of the variable character field can be anything from zero to the maximum declared field length. The method of declaring a variable character field differs according to the programming language used.

One of the biggest advantages of variable character fields is the avoidance of padding. In the case of a character field, the field occupies the exact number of characters regardless of the actual size of the string, and the difference between the fixed length and field length is padded with spaces. Unlike a character field, a variable character field only utilizes the space required for the size of the string, so only the minimum storage space is required. It helps in avoiding any wastage, and this feature is helpful in searching and sorting of values. In some databases and programming languages, any extra space found is automatically removed before storing to the database.

Based on the database or the programming language, there could be limitations on a variable character field, such as it cannot be used with select statement or cannot be used as a candidate or primary key.

Most relational database management systems support the variable character field.

Advertisements

Related Terms

Margaret Rouse
Technology expert
Margaret Rouse
Technology expert

Margaret is an award-winning writer and educator known for her ability to explain complex technical topics to a non-technical business audience. Over the past twenty years, her IT definitions have been published by Que in an encyclopedia of technology terms and cited in articles in the New York Times, Time Magazine, USA Today, ZDNet, PC Magazine, and Discovery Magazine. She joined Techopedia in 2011. Margaret’s idea of ​​a fun day is to help IT and business professionals to learn to speak each other’s highly specialized languages.