SQL data type

SQL data type defines the type and range of the data that can be used with SQL Server.

Commonly used SQL data types:

Data TypeSyntaxDescription
integerinteger Integer number.
smallintsmallint Small integer number.
numericnumeric(p,s)Where p is a precision value; s is a scale value. For example, numeric(7,3) is a number that has 4 digits before the decimal and 3 digits after the decimal.
decimaldecimal(p,s)Where p is a precision value; s is a scale value.
realrealSingle-precision floating point number
double precisiondouble precisionDouble-precision floating point number
floatfloat(p)Where p is a precision value.
characterchar(x)Where x is the number of characters to store. This data type is space padded to fill the number of characters specified.
character varyingvarchar2(x)Where x is the number of characters to store. This data type does NOT space pad.
bitbit(x)Where x is the number of bits to store.
bit varyingbit varying(x)Where x is the number of bits to store. The length can vary up to x.
datedateStores year, month, and day values.
timetimeStores the hour, minute, and second values.
timestamptimestampStores year, month, day, hour, minute, and second values.
time with time zonetime with time zoneExactly the same as time, but also stores an offset from UTC of the time specified.
timestamp with time zonetimestamp with time zoneExactly the same as timestamp, but also stores an offset from UTC of the time specified.

No comments: