Every column must be declared to have a datatype, also called a domain. This tells the database system how to represent the data internally. The datatypes can be grouped into several categories.
Description | SQL | MS Access | MySQL |
---|---|---|---|
Numeric Data | |||
binary integer 1 byte | NUMBER, BYTE | TINYINT [UNSIGNED] | |
binary integer 2 bytes | SMALLINT | NUMBER, INTEGER | SMALLINT [UNSIGNED] |
binary integer 4 bytes | INTEGER INT |
NUMBER - LONG INTEGER | INT [UNSIGNED] INTEGER [UNSIGNED] |
binary integer 8 bytes | BIGINT [UNSIGNED] | ||
floating-point 4 bytes |
FLOAT(p) REAL |
NUMBER, SINGLE | FLOAT |
floating-point 8 bytes |
DOUBLE PRECISION | NUMBER, DOUBLE | DOUBLE, REAL DOUBLE PRECISION |
decimal | DECIMAL(d, p) DEC(d, p) NUMERIC(d, p) |
NUMBER, DECIMAL(d, p) | DECIMAL(d, p) |
Character Data | |||
character fixed length |
CHAR(len) CHARACTER(len) |
see variable | CHAR(len) |
character variable length |
VARCHAR(maxlen) | TEXT(maxlen) -- n<256 | VARCHAR(maxlen) -- n: 0..255 |
CLOBs = Character large objects |
MEMO -- up to 65,587 bytes | TINYTEXT -- 0..255 TEXT -- 0..65535 MEDIUMTEXT LONGTEXT |
|
Time Data | |||
Date | DATE | DATE, TIME -- 8 bytes | DATE |
Time | TIME | ||
Date and Time | TIMESTAMP(p) | DATETIME, YEAR, TIMESTAMP | |
Money | |||
Money | MONEY | CURRENCY -- 8 bytes | Use DECIMAL(d,p) |
Binary Data | |||
BLOBs = Binary large objects |
TINYBLOB -- 0..255 BLOB -- 0..65535 MEDIUMBLOB LONGBLOB |
||
Other | |||
Other | ENUM(value,...)
SET(value,...) |