Each table column in a database must be associated with a data type. This enables the database to store and manage the data efficiently. A data type is an attribute that specifies the type of data that the column can store.
Most commercial databases nowadays provide 2 types of data types - system data types and user-defined data types. System data types are commonly used data types that are defined by the database vendor. These system data types tend to be the same across most types of database. User-defined data types on the other hand, are defined by the user. User-defined data types are only used when the system data types are not sufficient or will cause inefficiency.
The following are some of the more common system data types:
Data type | Description |
Binary Varying |
Variable-length binary data with a maximum length of 8,000 bytes |
Char Varying |
Variable-length non-Unicode data with a maximum of 8,000 characters |
Character |
Fixed-length non-Unicode character data with a maximum length of 8,000 characters |
Dec |
Fixed precision and scale numeric data from -10^38 +1 through 10^38 –1 |
Double Precision |
Floating precision number data with the following valid values:
-1.79E + 308 through -2.23E - 308, 0 and 2.23E + 308 through 1.79E + 308 |
Integer |
Integer (whole number) data from -2^31 (-2,147,483,648) through 2^31 - 1 (2,147,483,647) |
National Character |
Fixed-length Unicode data with a maximum length of 4,000 characters. |
National Character Varying |
Variable-length Unicode data with a maximum length of 4,000 characters |
RowVersion or TimeStamp |
A database-wide unique number that gets updated every time a row gets updated |
DateTime |
Date and time data from January 1, 1753, through December 31, 9999, with an accuracy of three-hundredths of a second, or 3.33 milliseconds |
(the above are excerpted from SQL Server documentation)
Each database vendor would have their own system data types but the common ones (see above) tend to be very similar with the data types defined by the ANSI-ISO SQL 92 standards. However, it would still be wise to test any database application out with the different database types to qualify the database application for each database type.