Database Reference
In-Depth Information
tional Standards Institute (ANSI) and the International Organization for Standardization
(ISO). Although the current version of the standard (as of this writing) is SQL 2011, most
major RDBMS programs still seem to be supporting earlier versions of SQL, such as SQL/
92 and SQL 2008.
The SQL standard defines eight major data types, and each data type has one or more
uniquely named variations. Here's a brief definition of each data type.
1. Character: This data type stores a fixed- or varying-length character string of one
or more printable characters. A fixed-length Character data type is known as
CHARACTER or CHAR, and a varying-length Character data type is known as
CHARACTER VARYING, CHAR VARYING, or VARCHAR.
2. National Character: This data type is the same as the Character data type, but it
can also store characters from foreign-language character sets. A fixed-length Na-
tional Character data type is known as NATIONAL CHARACTER, NATIONAL
CHAR, or NCHAR, and a varying-length National Character data type is known as
NATIONAL CHARACTER VARYING, NATIONAL CHAR VARYING, or
NCHAR VARYING.
3. Binary: This data type stores binary data such as images, sounds, videos, or com-
plex embedded documents such as word processing files or spreadsheets. This data
type is often referred to as BIT or BIT VARYING.
4. Exact Numeric: This data type stores whole numbers and numbers with decimal
places. Most RDBMS programs implement an Exact Numeric as NUMERIC,
DECIMAL (DEC), INTEGER (INT), BIGINT, or SMALLINT, and each variation
determines the range of values that the field will accept.
5. Approximate Numeric: This data type stores numbers with decimal places and ex-
ponential numbers. Most RDBMS programs implement an Approximate Numeric
as FLOAT, REAL, or DOUBLE PRECISION, and each variation determines the
range of values that the field will accept.
6. Boolean: This data type stores true and false values, usually in a single binary bit.
Some RDBMS programs use BIT, INT, or TINYINT to store this data type.
7. DateTime: This data type is commonly known as DATE, TIME, or TIMESTAMP
in most RDBMS programs, and it stores dates, times, and combinations of both.
Note that the implementation of this data type varies widely among RDBMS pro-
grams, so you must make absolutely certain that you refer to the RDBMS's docu-
mentation to determine how the RDBMS handles dates and times.
8. Interval: This data type stores the quantity of time between two DateTime values,
expressed either as year, month, year/month day, time, or day/time. Not all major
Search WWH ::




Custom Search