SQL Data Types
Learn the data types of columns in the database tables.
SQL Server and other relational database management systems use data types to hold data in specific columns.
Different data types are available, depending on the data that we want to store. For instance, we may want to store currency values, a product number, and a product description. There are certain data types that we must use to store that information. Most data types between each RDBMS (keynote: Relational database management systems) are relatively the same, though their names differ slightly, like SQL Server and MySQL. There are many data types that we use more than others. There are some common data types that we might use in the future.
The VARCHAR
data type
The VARCHAR
data type is an alphanumeric data type that holds strings like first and last names or email addresses. We can specify our VARCHAR
data type length with VARCHAR(n)
when creating a table. The value can be anywhere from 1 to 8,000, or we can substitute MAX
, which is . However, we rarely use this.
When designing our tables, we estimate the length of the longest string plus a few bytes. If the string that we want to store is around 30 characters, we may want to specify VARCHAR(40)
as an estimated data type length. This data type is flexible as it will fit only the characters entered into it, even if ...