Explain the SQL - Data Types

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 Stores TRUE or FALSE values
VARBINARY(n) or
BINARY VARYING(n) Binary string. Variable length. Maximum length n
INTEGER(p) Integer numerical (no decimal). Precision p
SMALLINT Integer numerical (no decimal). Precision 5
INTEGER Integer numerical (no decimal). Precision 10
BIGINT Integer numerical (no decimal). Precision 19
DECIMAL(p,s) Exact numerical, precision p, scale s. Example: decimal(5,2) is a number that has 3 digits before the decimal and 2 digits after the decimal
NUMERIC(p,s) Exact numerical, precision p, scale s. (Same as DECIMAL)
FLOAT(p) Approximate numerical, mantissa precision p. A floating number in base 10 exponential notation. The size argument for this type consists of a single number specifying the minimum precision
REAL Approximate numerical, mantissa precision 7
FLOAT Approximate numerical, mantissa precision 16
DOUBLE PRECISION Approximate numerical, mantissa precision 16
DATE Stores year, month, and day values
TIME Stores hour, minute, and second values
TIMESTAMP Stores year, month, day, hour, minute, and second values
INTERVAL Composed of a number of integer fields, representing a period of time, depending on the type of interval
ARRAY A set-length and ordered collection of elements
MULTISET A variable-length and unordered collection of elements
XML Stores XML data
 
integer

smallint


numeric(p,s: Where p is a precision value; s is a scale value. For example, numeric(6,2) is a number that has 4 digits before the decimal and 2 digits after the decimal.
decimal(p,s): Where p is a precision value; s is a scale value.
real: Single-precision floating point number
double precision: Double-precision floating point number
float(p): Where p is a precision value.
char(x): Where x is the number of characters to store. This data type is space padded to fill the number of characters specified.
varchar(x): Where x is the number of characters to store. This data type does NOT space pad.
bit(x): Where x is the number of bits to store.
bit varying(x): Where x is the number of bits to store. The length can vary up to x.
date: Stores year, month, and day values.
time: Stores the hour, minute, and second values.
timestamp: Stores year, month, day, hour, minute, and second values.
time with time zone: Exactly the same as time, but also stores an offset from UTC of the time specified.
timestamp with time zone: Exactly the same as timestamp, but also stores an offset from UTC of the time specified.
year-month interval: Contains a year value, a month value, or both.
day-time interval: Contains a day value, an hour value, a minute value, and/or a second value.
 
Back
Top