WEB DEVELOPER SITE
HTMLCSSJAVASCRIPTSQLPHPBOOTSTRAPJQUERYANGULARXML
 

SQL General Data Types


The data type defines the kind of value stored in the column.


SQL Common Data Types

Each column in a database table requires a name and data type. Each column in a database table is required to have a name and a data type.

SQL developers must decide when creating a SQL table what type of data each column in the table will store. A data type is a label that is a guide for SQL to understand what type of data each column expects to store. It also identifies how SQL interacts with the stored data.

The following table lists the common data types in SQL:

Data type Description
CHARACTER (n) character /string. Fixed length n.
VARCHAR (n) or
CHARACTER VARYING (n)
character /string. Variable length. Maximum length n.
BINARY (n) Binary string. Fixed length n.
BOOLEAN Store TRUE or FALSE values ​​
VARBINARY (n) or
BINARY VARYING (n)
Binary string. Variable length. Maximum length n.
INTEGER (p) Integer value (no decimal point). Precision p.
SMALLINT Integer value (no decimal point). Precision 5.
INTEGER Integer value (no decimal point). Precision 10.
BIGINT Integer value (no decimal point). Precision 19.
DECIMAL (p, s) Exact value, precision p, s after the decimal point. For example: decimal (5,2) is a number with 3 digits before the decimal point and 2 digits after the decimal point.
NUMERIC (p, s) Exact value, precision p, s after the decimal point. (Same as DECIMAL)
FLOAT (p) approximate value, mantissa precision p. A floating-point number with a base 10 exponential method. The size parameter of this type consists of a single number specifying the smallest precision.
REAL Approximate value with mantissa precision 7.
FLOAT Approximate value with mantissa precision of 16.
DOUBLE PRECISION Approximate value with mantissa precision of 16.
DATE stores the year, month, and day values.
TIME stores the hour, minute, and second values.
TIMESTAMP stores the year, month, day, hour, minute, and second values.
INTERVAL consists of integer fields, representing a period of time, depending on the type of interval.
ARRAY A fixed-length ordered collection of elements
MULTISET A variable-length unordered collection of elements
XML Storing XML data


Quick Reference Manual for SQL Data Types

However, different databases provide different options for data type definitions.

The following table shows the common names of some data types on various database platforms:

type of data Access SQLServer Oracle MySQL PostgreSQL
boolean Yes/No Bit Byte N/A Boolean
integer Number (integer) Int Number Int
Integer
Int
Integer
float Number (single) Float
Real
Number Float Numeric
currency Currency Money N/A N/A Money
string (fixed) N/A Char Char Char Char
string (variable) Text (<256)
Memo (65k+)
Varchar Varchar
Varchar2
Varchar Varchar
binary object OLE Object Memo Binary (fixed up to 8K)
Varbinary (<8K)
Image (<2GB)
Long
Raw
Blob
Text
Binary
Varbinary

lamp

Note: The same data type may have different names in different databases. Even if the name is the same, the dimensions and other details may be different! Please always check the documentation!