SQL Data Types – SQL Tutorial | Software Testing Material
SQL Data Types:
In this post, we see SQL Data Types in detail.
In SQL Server, each column in a database table has a name and a data type. We need to decide what type of data to store inside each and every column of a table while creating a SQL table.
SQL Server supplies a set of system data types that define all types of data that can be used with the SQL Server.
SQL Server offers following categories of data types:
Let’s see the SQL Data Types in detail.
Exact Numeric SQL Data Types:
bigint = Range from -2^63 (-9,223,372,036,854,775,808) to 2^63-1 (9,223,372,036,854,775,807)
int = Range from -2^31 (-2,147,483,648) to 2^31-1 (2,147,483,647)
smallint = Range from -2^15 (-32,768) to 2^15-1 (32,767)
tinyint = Range from 0 to 255
bit =Â 0 and 1
decimal = Range from –10^38 +1 to 10^38 -1
numeric =Â Range from -10^38 +1 to 10^38 -1
money =Â Range from -922,337,203,685,477.5808 to +922,337,203,685,477.5807
small money =Â Range from -214,748.3648 to +214,748.3647
Approximate Numeric SQL Data Types:
float = Range from -1.79E + 308 to 1.79E + 308
real = Range from -3.40E + 38 to 3.40E + 38
Date and Time SQL Data Types:
datetime = From Jan 1, 1753 to Dec 31, 9999
smalldatetime = From Jan 1, 1900 to Jun 6, 2079
date = To store a date like March 27, 1986
time = To store a time of day like 12:00 A.M.
Character Strings SQL Data Types:
char = Maximum length of 8,000 characters
varchar = Maximum of 8,000 characters
varchar(max) = Maximum length of 231Â characters
text = Maximum length of 2,147,483,647 characters.
Unicode Character Strings SQL Data Types:
nchar = Maximum length of 4,000 characters
nvarchar = Maximum length of 4,000 characters
nvarchar(max) = Maximum length of 231Â characters
ntext = Maximum length of 1,073,741,823 characters
Binary SQL Data Types:
binary = Maximum length of 8,000 bytes
varbinary = Maximum length of 8,000 bytes
varbinary(max) = Maximum length of 231 bytes
image = Maximum length of 2,147,483,647 bytes
In the next tutorial, we will see Operators In SQL
Check out the complete SQL Tutorial by clicking on below link: