Data types

Drupal supports multiple databases through its database abstraction layer.     

Each module that wants to have a database table describes that table to Drupal using a schema definition. In Drupal's schema definition, tables and field types are defined in a way it can be mapped to any database. Drupal's Schema API does this heavy task of translating the definition into the syntax that is appropriate for the database.

This guide will help you to get very comfortable with using Schema API to define tables and fields. This guide will also help you to decide the right data type for your field.

Data types overview

A table showing all the combinations of the 'type' and 'size' fields of a column specification along with underlying database data types.


Serial is a self-incrementing Integer data type


This field type is used for storing integers, such as node IDs and user IDs.


Floating point numbers are stored using the float data type.

Decimal (Numeric)

The numeric data type allows us to specify the precision and scale of a number.


Text data type is used to store quite large textual data, for example, the body field of a node.


The Varchar type is the most frequently used field type for storing text less than 256 characters in length.


Char fields are fixed-length character fields. The length of the field, in characters, is defined by the length key.


The binary large object data (blob) type is used to store binary data (for example, Drupal’s cache table to store the cached data).

Encoding, Collation and Storage

A Crash course on Character encoding, Collation and Storage Engines

Guide maintainers