I have following confusions -
1. Which datatype is used for bigger amount of data store
2. When we specify varcha(100) so this 100 represent 100 characters
or 100 bits or bytes
views:
53answers:
5Assuming you are talking about MS SQL Server:
1) varchar(max)
: varchar(max)
is a replacement for TEXT
2) varchar(100)
= 100 characters (single byte ascii chars)
(whereas nvarchar(100)
= 100 characters (double byte unicode chars))
Ref: char and varchar (Transact-SQL)
[Just found a possible duplicate: ms sql server; varchar(MAX) vs TEXT ]
TEXT will store up to 64K - MySQL (for example) provides variants as well: TINYTEXT (256 bytes), MEDIUMTEXT (16MB) and LONGTEXT (4GB).
A VARCHAR(100) column will hold up to 100 characters of text. You can use a VARBINARY for binary data, in which case a VARBINARY(100) field will hold up to 100 bytes.
On SQL Server
varchar(100) = 100 ascii characters and 102 bytes
nvarchar(100) = 100 unicode/ascii characters and 202 bytes of storage
text and ntext go up to 2GB but are deprecated (from sql server 2005), you should use varchar(max) and nvarchar(max) which both also go up to 2 GB instead
The datatype TEXT is limited to 4000 characters where in the new data type Varchar(max) is meant to store Maximum Length of characters or the length that you specified
For more information check this
If using MySQL
the difference is mainly related to the storage requirements:
VARCHAR
:L + 1
bytes if column values require 0 – 255 bytes,L + 2
bytes if values may require more than 255 bytesTEXT
:L + 2
bytes, whereL < 2^16
where L
is the actual size of the entry