
Your data, our passion.
Snack-Sized Data Basics
Data Types - Text
Text data types are used to store strings. We haven’t covered what a string is yet, so here it is.
​
A string is a sequence of characters, which can include letters, numbers, symbols and spaces.
​​

There are different types of text data types used in SQL. Here are a few:​
-
CHAR stores a fixed number of characters. For example, CHAR(10) always stores exactly 10 characters, no more, no less. This is useful when the column data is expected to have a consistent length.
For example, CHAR(5) is a good choice for storing standard U.S. zip codes since they are always 5 characters long. -
VARCHAR allows varied lengths, but up to the defined limit.
For example, with VARCHAR(11), you can store "Hello" or "Hello there" or just "Hey". -
TEXT is used for storing large amounts of text, capable of holding thousands of characters. It's commonly used for content like articles or long descriptions.​​​​
​​
Question: What data type would you use to store first names?
​
​Answer: VARCHAR(50) would be appropriate in this situation, as it provides enough space for long first names. The length doesn't have to be exactly 50, but it should be long enough to accommodate the longest expected first name without wasting unnecessary space.
Some examples are names, messages, song lyrics, or addresses. While there are specific data types for numbers, as we've seen, text data types can also store numbers. However, string numbers are typically not used for calculations.
​​