String data types in SQL


In this chapter you will learn:

What is string data type?
Types of string data type

What is string data type?

The data type which store the value in the form of string, word or character is called string data type. There are so many string data types that are used in sql to store different string value. Here you will get string data types in the below given table.


Data typesRangeUsed to storeStorage (Bytes)
char(n)n characters, where n can be 1 to 8000Fixed length character datan
varchar(n)n characters, where n can be 1 to 8000Variable length character datan+2
textMaximum length of 2^31-1 (2,147,483,647) charactersCharacter stringVariable size
ntextMaximum length of 2^30-1 (1,073,741,823) charactersVariable length Unicode dataVariable size
bit0 or 1Integer data with 0 or 1Variable size
imageMaximum length of 2^31-1 (2,147,483,647) bytesVariable Length binary data to store imagesVariable size
real-3.40E + 38 to -1.18E-38, 0 and 1.18E-38 to 3.40E + 38Floating Precision number4
binaryMaximum length of 8000 bytesFixed length binary datan (length of data)
varbinaryMaximum length of 8000 bytesVariable length binary datan (length of data) +2
tinytextMaximum length of 255 charactersCharacter stringVariable size
ncharMaximum length of 4000 charactersFixed length Unicode datan (length of data) * 2
nvarcharMaximum length of 4000 charactersVariable length Unicode datan (length of data) * 2+2
varchar(max)Maximum 1,073,741,824 charactersVariable width character string2 bytes + number of chars
nvarchar(max)Maximum 536,870,912 charactersVariable width Unicode stringVariable size
blobUp to 65,535 bytes of dataBinary Large OBjects65,535
mediumblobUp to 16,777,215 bytes of dataBinary Large OBjects1,67,77,215
longblobUp to 4,294,967,295 bytes of dataBinary Large OBjects4,29,49,67,295
mediumtextMaximum length of 16,777,215 charactersCharacter stringVariable size
longtextMaximum length of 4,294,967,295 charactersCharacter stringVariable size


In this chapter you have learned about string data type and its values. In the next chapter you will study about what is number data types and how many number data types are available in SQL?

Leave a Reply

Your email address will not be published. Required fields are marked *