Last updated October 12, 2016. Created on August 22, 2010.
Edited by Christopher James Francis Rodgers, chx, arianek, yched. Log in to edit this page.

The Field SQL Storage module provides data management for the Field module. This module uses the Field API to generate dynamic data tables for entities and fields. While this is a required core module, it may be replaced by other contributed modules that implement The Field Storage API.


This module is an internal developer API and provides no user interface.


Drupal 7

The Field SQL Storage module was introduced in Drupal 7.


Default module: Yes
Dependencies: Field
Related Modules: Field
Permissions: None
API Documentation: Field storage API
Database tables:

You might find this information in $field['storage']['details'];. The usage of this array is very strongly discouraged and is known not to work in certain cases, like inside hook_update_N

Looking for support? Visit the forums, or join #drupal-support in IRC.


rooby’s picture

If it is recommended to use _field_sql_storage_tablename() & _field_sql_storage_revision_tablename() why are they private functions?

heddn’s picture

I ignored the comment in the above guide without issue. But note, other backends don't have a fully implemented hook_field_storage_details() so this really provide an easy method to gather table & column names on sql backed storage.

  $schema = example_field_schema_7000();
  $fields = field_read_fields(array('type' => 'example_type'));
  $field_info = new FieldInfo();
  foreach ($fields as $field) {
    $prepared = $field_info->prepareField($field);
    foreach ($prepared['storage']['details'] as $storage) {
      // This is known to work with sql storage backend, but not others.
      // For example, mongodb has an empty hook_field_storage_details().
      $age_arguments = array(FIELD_LOAD_CURRENT, FIELD_LOAD_REVISION);
      foreach ($age_arguments as $age) {
        if (empty($storage[$age])) {
          throw new DrupalUpdateException('Unsupported storage backend');
        foreach ($storage[$age] as $table => $columns) {
          foreach ($columns as $name => $column) {
            if (!db_field_exists($table, $column)) {
              db_add_field($table, $column, $schema['columns'][$name]);
Kebz’s picture

I was wondering... can anyone PLEASE help me with this. I am completely locked out of my website. So the only solutions are ... create the "missing" table it is looking for -- or uninstall the "membership" modules - or restore database to how it was before this error came up.

I need to do something because I can't have it sit in this mode and I have people waiting for my site to go live.

How to recover from this ERROR below??

PDOException: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'dbxxx.xxxfield_data_membership_entity_term_ref' doesn't exist: SELECT t.* FROM {field_data_membership_entity_term_ref} t WHERE (entity_type = :db_condition_placeholder_0) AND (entity_id IN (:db_condition_placeholder_1)) AND (language IN (:db_condition_placeholder_2)) AND (deleted = :db_condition_placeholder_3) ORDER BY delta ASC; Array ( [:db_condition_placeholder_0] => commerce_line_item [:db_condition_placeholder_1] => 1 [:db_condition_placeholder_2] => und [:db_condition_placeholder_3] => 0 ) in field_sql_storage_field_storage_load() (line 392 of .../modules/field/modules/field_sql_storage/field_sql_storage.module).

DatabaseStatementBase->execute(Array, Array)
DatabaseConnection->query('SELECT t.*
{field_data_membership_entity_term_ref} t
WHERE (entity_type = :db_condition_placeholder_0) AND (entity_id IN (:db_condition_placeholder_1)) AND (language IN (:db_condition_placeholder_2)) AND (deleted = :db_condition_placeholder_3)
ORDER BY delta ASC', Array, Array)
SelectQuery->execute() field_sql_storage.module:392
field_sql_storage_field_storage_load('commerce_line_item', Array, 'FIELD_LOAD_CURRENT', Array, Array)
call_user_func_array('field_sql_storage_field_storage_load', Array)
module_invoke('field_sql_storage', 'field_storage_load', 'commerce_line_item', Array, 'FIELD_LOAD_CURRENT', Array, Array)
field_attach_load('commerce_line_item', Array)
DrupalDefaultEntityController->attachLoad(Array, )
CommerceLineItemEntityController->attachLoad(Array, ) entitycache.module:108
EntityCacheControllerHelper::entityCacheLoad(Object, Array, Array)
CommerceEntityCacheCommerceLineItemEntityController->load(Array, Array)
entity_load('commerce_line_item', Array)
EntityStructureWrapper->__get('type') commerce_line_item.module:1434
commerce_line_items_quantity(Object, Array) commerce_cart.module:80
call_user_func_array('commerce_cart_menu_item_title', Array)
_menu_item_localize(Array, Array, 1)
menu_tree_check_access(Array, Array)
menu_build_tree('user-menu', Array)
menu_tree_all_data('user-menu') superfish.module:1548
theme('superfish', Array) superfish.module:1003
superfish_contents('1') superfish.module:1075
call_user_func_array('superfish_block_view', Array)
module_invoke('superfish', 'block_view', '1') block.module:902
_block_render_blocks(Array) block.module:686
block_list('highlighted') block.module:318
block_get_blocks_by_region('highlighted') block.module:268
drupal_deliver_page(Array, '')
menu_execute_active_handler() index.php:21