Data types overview
Drupal 7 will no longer be supported after January 5, 2025. Learn more and find resources for Drupal 7 sites
The following table shows all the legal combinations of the 'type' and 'size' fields of a column specification along with the underlying database data types used by each combination. As of Drupal 7, MySQL, PostgreSQL, and SQLite data types are supported in Drupal core. Drupal 6 core supports MySQL and PostgreSQL.
The maximum size or range of each underlying type is also shown. For integer types, the number of storage bytes is given; the maximum range depends on whether the field is signed or unsigned. For varchar, text, and blob types, the maximum size is given.
type | size | MySQL type & size/range | PostgreSQL type & size/range | SQLite type |
---|---|---|---|---|
serial | tiny | tinyint, 1 B | serial, 4 B | integer |
serial | small | smallint, 2 B | serial, 4 B | integer |
serial | medium | mediumint, 3 B | serial, 4 B | integer |
serial | big | bigint, 8 B | bigserial, 8 B | integer |
serial | normal | int, 4 B | serial, 4 B | integer |
int | tiny | tinyint, 1 B | smallint, 2 B | integer |
int | small | smallint, 2 B | smallint, 2 B | integer |
int | medium | mediumint, 3 B | int, 4 B | integer |
int | big | bigint, 8 B | bigint, 8 B | integer |
int | normal | int, 4 B | int, 4 B | integer |
float | tiny | float, 4 B | real, 6 digits | float |
float | small | float, 4 B | real, 6 digits | float |
float | medium | float, 4 B | real, 6 digits | float |
float | big | double, 8 B | double precision, 15 digits | float |
float | normal | float, 4 B | real, 6 digits | float |
numeric | normal | numeric, 65 digits | numeric, 1000 digits | numeric |
varchar | normal | varchar, 255 B (D6) or 64 KB (D7 and later) [1] | varchar, 1 GB | varchar |
char | normal | char, 255 B | character, 1 GB | (UNSUPPORTED) |
text | tiny | tinytext, 256 B | text, unlimited | text |
text | small | tinytext, 256 B | text, unlimited | text |
text | medium | mediumtext, 16 MB | text, unlimited | text |
text | big | longtext, 4 GB | text, unlimited | text |
text | normal | text, 16 KB | text, unlimited | text |
blob [2] | big | longblob, 4 GB | bytea, 4 GB | blob |
blob [2] | normal | blob, 16 KB | bytea, 4 GB | blob |
datetime [3] | normal [3] | datetime, years 1001 CE to 9999 CE [3] | timestamp, years 4713 BCE to 5874897 CE [3] | (UNSUPPORTED) [3] |
[1] MySQL 5.0.3 or later (see http://dev.mysql.com/doc/refman/5.0/en/char.html).
PostgreSQL 9.0 or later (see http://www.postgresql.org/docs/9.0/static/datatype.html).
SQLite 3.0 or later (see http://www.sqlite.org/datatype3.html).
[2] For database portability blob fields must be used to store serialized data since PHP adds null bytes if objects are serialized. Null bytes cannot be stored in Postgres text or varchar fields.
[3] Note that DateTime support was removed from D7 DB API - use mysql_type or pgsql_type if you want this functionality
Help improve this page
You can:
- Log in, click Edit, and edit this page
- Log in, click Discuss, update the Page status value, and suggest an improvement
- Log in and create a Documentation issue with your suggestion