Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

variable length field in Database

Is there any way to store variable length list into database in SQL or any other database engine ??

Here list means no. of elements in the array. For e.g. an array of numbers.

But in my actual application things to be stored are objects and hence cannot be stored simply as comma separated list.

like image 236
Mahesh Gupta Avatar asked Dec 22 '10 07:12

Mahesh Gupta


People also ask

What is the variable of length?

Variable length refers to anything whose length can vary. For example, in databases, a variable-length field is a field that does not have a fixed length. Instead, the field length varies depending on what data is stored in it.

What are fixed length fields What are variable length field?

Fixed length means having a set length that never varies. In database systems, a field can have a fixed or a variable length. A variable-length field is one whose length can be different in each record, depending on what data is stored in the field.

What is variable length string data type?

There are two kinds of strings: variable-length and fixed-length strings. A variable-length string can contain up to approximately 2 billion (2^31) characters. A fixed-length string can contain 1 to approximately 64 K (2^16) characters.

Is CHAR a variable length field?

CHAR is conceptually a fixed-length, blank-padded string. Trailing blanks (spaces) are removed on input, and are restored on output. The default length is 1, and the maximum length is 65000 octets (bytes). VARCHAR is a variable-length character data type.


1 Answers

Some SQL databases support the ARRAY type as the type of a column. An ARRAY is variable length and can hold objects of the same type. See details below which apply to databases that support the SQL Standard:

http://hsqldb.org/doc/2.0/guide/sqlgeneral-chapt.html#N106FE

like image 136
fredt Avatar answered Sep 20 '22 13:09

fredt