TechnoLearnAcademy

TECHNOLEARN

SQL DATA TYPES

DATA TYPES are used to store the type of data that can be stored in a column of a  database table.
    There are three categories of data types.
    • String Data Types
    • Numeric Data Types
    • Date and Time Data Types
String Data Types

Data Types

Description

Size

Storage

char(n)

Fixed width character string

8,000 characters

Defined width

varchar(n)

variable width character string

8,000 characters

2 bytes + number of chars

varchar(max)

variable width character string

1073741824 characters

2 bytes + number of chars

nchar(n)

variable width unicode string

4000 characters

nvarchar(n)

variable width unicode string

536870912 characters

nvarchar(max)

variable width unicode string

536870912 characters

Numeric Data Types

Data Types

Description

Storage

bit

0,1 or null

tinyint

whole numbers from 0 to 255

1 byte

smallint

whole numbers from -32,768 to 32,767

2 byte

int

whole numbers from -2,147,483,648 and 2,147,483,647

4 byte

bigint

whole numbers from -9,223,372,036,854,775,808 and 9,223,372,036,854,775,807

8 byte

Date Data Types

Data Type

Description

Storage

Date

Store a date only. From January 1, 0001 to December 31, 9999

3 bytes

Time

Store a time only to an accuracy of 100 nanoseconds

3-5 bytes

datetime

From January 1, 1753 to December 31, 9999 with an accuracy of 3.33 milliseconds

8 bytes

smalldatetime

From January 1, 1900 to June 6, 2079 with an accuracy of 1 minute

4 bytes

Scroll to Top