What is the difference between TEXT and VARCHAR data fields?

I have the following confusion -
1. What type of data is used for more data storage
2. When we specify varcha (100), so 100 represents 100 characters or 100 bits or bytes

+7
types text varchar
source share
5 answers

In 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 2 GB, but are deprecated (from sql server 2005), you should use varchar (max) and nvarchar (max), which both also go up to 2 GB instead

+4
source share

TEXT will store up to 64K - MySQL (for example) also provides options: TINYTEXT (256 bytes), MEDIUMTEXT (16 MB) and LONGTEXT (4 GB).

The VARCHAR (100) column holds up to 100 characters of text. You can use VARBINARY for binary data, in which case the VARBINARY (100) field will contain up to 100 bytes.

+2
source share

When using MySQL difference is mainly related to storage requirements :

  • VARCHAR : L + 1 bytes if column values ​​require 0 - 255 bytes, L + 2 bytes if values ​​may require more than 255 bytes

  • TEXT : L + 2 bytes, where L < 2^16

where L is the actual record size

+2
source share

Assuming 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 characters)

(whereas nvarchar(100) = 100 characters (double-byte Unicode characters))

Ref: char and varchar (Transact-SQL)

[Just found duplicate: ms sql server; varchar (MAX) vs TEXT ]

+1
source share

The TEXT data type is limited to 4000 characters, where in the new data type Varchar (max) is designed to store the maximum character length or the length you specify

For more information check this out.

http://databases.about.com/od/sqlserver/a/char_string.htm

0
source share

All Articles