September 17th, 2008

Introduction to Data Types, Part 1 of 3

Posted by admin in F. Data Types

Each column in a table has a single data type.
The data type determines the allowable values, and what operations can be performed on the data.
Arithmetic operations can be performed on numeric data types.
Concatenation can be performed on string data types.

The four basic data type groups are:

Character: CHAR(length) .... VARCHAR(length) .... LONG VARCHAR(length)
Graphic:   GRAPHIC(length) . VARGRAPHIC(length) . LONG VARGRAPHIC(length)
Numeric:   SMALLINT ........ INTEGER ............ DECIMAL(precision,scale) . FLOAT(precision)
Date/Time: DATE ............ TIME ............... TIMESTAMP ................ INTERVAL

> Character and graphic data can be grouped into a larger category called string data.
> Use CREATE TABLE or ALTER TABLE to define or change a column’s data type.
> Data type affects the column’s sort order. You can sort SELECTed data by using ORDER BY.
Numeric 11, 10, 1, 2, 3 is sorted to 1, 2, 3, 10, 11.
Characters ’11′, ’10′, ’1′, ’2′, ’3′ is sorted to ’1′, ’10′, ’11′, ’2′, ’3′.
> Some data types such as LONG VARCHAR, GRAPHIC, VARGRAPHIC, and LONG VARGRAPHIC are rarely used.
> VARCHAR and LONG VARCHAR should only be used at the end of a row as explained later.
> SQL-89 defined a minimum of data set types, but it omitted some of the most useful and popular types, such as dates, times, and variable-length characters.
> SQL-92 included these useful data types, but didn’t address newer types, such as graphics and multimedia.
> SQL:2003 dropped SQL-92′s bit string data type such as BIT and BIT VARYING.
> Other data types may be implemented by the RDBMS vendors.

Comments are closed.

Sorry, the comment form is closed at this time.