Prev Next
Data storage format of an object is defined by SQL data types. These objects can be a variable or columns or expressions and data can be numeric, character, string, binary, date and time etc.
Numeric Data Types in SQL:
- BIGINT – Stores big integer numbers, values from -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807
- INTEGER – Stores integer number, values from -2,147,483,648 to 2,147,483,647
- SMALLINT – Stores small integer number, values from -32,768 to 32,767
- TINYINT – Stores tiny integer number, values from 0 to 255
- NUMERIC(P,S) – Stores values from -10^38 +1 to 10^38 -1. Where ‘p’ is precision value and ‘s’ is scale value.
- REAL – Single precision floating point number, stores values from -3.40E + 38 to 3.40E + 38
- DECIMAL(P,S) – Stores values from -10^38 +1 to 10^38 -1, where ‘p’ is precision value and ‘s’ is scale value.
- FLOAT(P) – Stores values from -1.79E + 308 to 1.79E + 308, where ‘p’ is precision value.
- DOUBLE PRECISION – Double precision floating point number.
- BIT(X) – Where ‘x’ is the number of bits to store, stores value from 0 to 1
- BIT VARYING(X) – X’ is the number of bits to store (length can vary up to x)2
Non-Unicode Character Data Types:
- CHAR(X) – Where ‘x’ is the character’s number to store. It can store upto 8,000 characters
- VARCHAR2(X) – Where ‘x’ is the character’s number to store. It can store upto 8,000 characters
- VARCHAR(MAX) – It can store upto 231 characters
- text – Can store upto 2,147,483,647 characters
Unicode Character Data Types:
- nCHAR(X) – Where ‘x’ is the character’s number to store. It can store upto 4,000 characters
- nVARCHAR2(X) – Where ‘x’ is the character’s number to store. It can store upto 4,000 characters
- nVARCHAR(MAX) – Can store upto 231 characters
- ntext – Can store upto 1,073,741,823 characters
Binary Data Types in SQL:
- binary – Can store upto 8,000 bytes (Fixed-length binary data)
- varbinary – Can store upto 8,000 bytes. (Variable length binary data)
- varbinary(max) – Can store upto 231 bytes (Variable length Binary data)
- image – Can store upto 2,147,483,647 bytes. ( Variable length Binary Data)
Date and Time Data Types in SQL:
- DATE – Stores month, days and year values.
- TIME – Stores hour, minute and second values.
- TIMESTAMP – It stores year, month, day, hour, minute and second values.
Misc Datatypes in SQL:
- cursor – This data type is a reference to a cursor object.
- xml – This data type Stores XML data.
- table – This data type stores result set for further processing.
- sql_variant – This data type stores some supported values of SQL Server data types.
- uniqueidentifier – This data type stores a globally unique identifier (GUID).