SQL Data Types

The data type determines the kind of values that users can store in the field. Like every programming languages, the SQL also has specific data type to store data. Following are some data type and there descriptions in which SQL allows us to store data.

Microsoft Access Data Types

Source: Microsoft Access Help

Setting Type of data Size
Text (Default) Text or combinations of text and numbers, as well as numbers that don't require calculations, such as phone numbers. Up to 255 characters or the length set by the FieldSize property, whichever is less. Microsoft Access does not reserve space for unused portions of a text field.
Memo Lengthy text or combinations of text and numbers. Up to 65,535 characters. (If the Memo field is manipulated through DAO and only text and numbers [not binary data] will be stored in it, then the size of the Memo field is limited by the size of the database.)
Number Numeric data used in mathematical calculations. For more information on how to set the specific Number type, see the FieldSize property topic. 1, 2, 4, or 8 bytes (16 bytes if the FieldSize property is set to Replication ID).
Date/Time Date and time values for the years 100 through 9999. 8 bytes.
Currency Currency values and numeric data used in mathematical calculations involving data with one to four decimal places. Accurate to 15 digits on the left side of the decimal separator and to 4 digits on the right side. 8 bytes.
AutoNumber A unique sequential (incremented by 1) number or random number assigned by Microsoft Access whenever a new record is added to a table. AutoNumber fields can't be updated. For more information, see the NewValues property topic. 4 bytes (16 bytes if the FieldSize property is set to Replication ID).
Yes/No Yes and No values and fields that contain only one of two values (Yes/No, True/False, or On/Off). 1 bit.
OLE Object An object (such as a Microsoft Excel spreadsheet, a Microsoft Word document, graphics, sounds, or other binary data) linked to or embedded in a Microsoft Access table. Up to 1 gigabyte (limited by available disk space)
Hyperlink Text or combinations of text and numbers stored as text and used as a hyperlink address. A hyperlink address can have up to three parts:

text to display—  the text that appears in a field or control.

address— the path to a file (UNC path) or page (URL).

subaddress— a location within the file or page.

screentip— the text displayed as a tooltip.

The easiest way to insert a hyperlink address in a field or control is to click Hyperlink on the Insert menu.

Each part of the three parts of a Hyperlink data type can contain up to 2048 characters.
Lookup Wizard Creates a field that allows you to choose a value from another table or from a list of values by using a list box or combo box. Clicking this option starts the Lookup Wizard, which creates a Lookup field. After you complete the wizard, Microsoft Access sets the data type based on the values selected in the wizard. The same size as the primary key field used to perform the lookup, typically 4 bytes.

SQL Server Data Types

Datatype Storage Type
Bigint 8 bytes Exact numeric
Int 4 bytes Exact numeric
Smallint 2 bytes Exact numeric
Tinyint 1 bytes Exact numeric
Bit 1 to 8 bit columns in the same table requires a total of 1 byte, 9 to 16 bits = 2 bytes, etc... Exact numeric
Decimal Precision 1-9 = 5 bytes, precision 10-19 = 9 bytes, precision 20-28 = 13 bytes, precision 29-38 = 17 bytes 
Exact numeric
Numeric

Money 8 bytes Exact numeric
Smallmoney 4 bytes Exact numeric
Float 4 bytes when precision is less than 25 and 8 bytes when precision is 25 through 53 Approximate numerics
Real 4 bytes Approximate numerics
Datetime 8 bytes Date and time
Smalldatetime 

Date and time
Date
Date and time
Time
Date and time
Datetime2 Presicion 1-2 = 6 bytes precision 3-4 = 7 bytes precision 5-7 = 8 bytes Date and time
Datetimeoffset Presicion 1-2 = 8 bytes precision 3-4 = 9 bytes precision 5-7 = 10 bytes Date and time
Char Defined width Character string
Varchar 2 bytes + number of chars Character string
Varchar(max) 2 bytes + number of chars Character string
Text 4 bytes + number of chars Character string
Nchar Defined width x 2 Unicode character string
Nvarchar
Unicode character string
Nvarchar(max)
Unicode character string
Ntext
Unicode character string
Binary
Binary string
Varbinary
Binary string
Varbinary(max)
Binary string
Image
Binary string
Sql_variant
Other
Timestamp
Other
Uniqueidentifier
Other
Xml
Other
Cursor
Other
Table
Other

MySQL Data Types

Type Size Description
CHAR[Length] Length bytes A fixed-length field from 0 to 255 characters long.
VARCHAR(Length) String length + 1 bytes A fixed-length field from 0 to 255 characters long.
TINYTEXT String length + 1 bytes A string with a maximum length of 255 characters
TEXT String length + 2 bytes A string with a maximum length of 65,535 characters.
MEDIUMTEXT String length + 3 bytes A string with a maximum length of 16,777,215 characters.
LONGTEXT String length + 4 bytes A string with a maximum length of 4,294,967,295 characters.
TINYINT[Length] 1 byte Range of -128 to 127 or 0 to 255 unsigned.
SMALLINT[Length] 2 bytes Range of -32,768 to 32,767 or 0 to 65,535 unsigned.
MEDIUMINT[Length] 3 bytes Range of -8,388,608 to 8,388,607 or 0 to 16,777,215 unsigned
INT[Length] 4 bytes Range of -2,147,483,648 to 2,147,483,647 or 0 to 4,294,967,295 unsigned
BIGINT[Length] 8 bytes Range of -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807 or 0 to 18,446,744,073,709,551,615 unsigned
FLOAT 4 bytes A small number with a  floating decimal point.
DOUBLE[Length, Decimals] 8 bytes A large number with a floating decimal point.
DECIMAL[Length, Decimals] Length +1 bytes or
Length + 2 bytes
A DOUBLE stored as a string, allowing for a fixed decimal point.
DATE 3 bytes In the format YYYY-MM-DD
DATETIME 8 bytes In the format YYYY-MM-DD HH:MM:SS.
TIMESTAMP 4 bytes In the format YYYYMMDDHHMMSS; acceptable range ends in the year 2037.
TIME 3 bytes In the format of HH:MM:SS.

Every DBMS has its own set of rules on the data type. Some are not SQL standards. The above list are simply a representation of most common term use to describe the meaning of every data type.

Add new comment