Search code examples
mysqldatabasedrupalprimary-keysequelpro

Why does Sequel Pro show a different result for a table's key values than MySQL on the command line?


This is the structure of a particular table in Sequel Pro:

Sequel Pro Table

This is that same table structure as viewed on the command line:

MySQL Command Line

Here is the output of SHOW CREATE TABLE field_data_field_checklist_status:

| field_data_field_checklist_status | 
CREATE TABLE `field_data_field_checklist_status` (
  `entity_type` varchar(128) NOT NULL DEFAULT '' COMMENT 'The entity type this data is attached to',
  `bundle` varchar(128) NOT NULL DEFAULT '' COMMENT 'The field instance bundle to which this row belongs, used when deleting a field instance',
  `deleted` tinyint(4) NOT NULL DEFAULT '0' COMMENT 'A boolean indicating whether this data item has been deleted',
  `entity_id` int(10) unsigned NOT NULL COMMENT 'The entity id this data is attached to',
  `revision_id` int(10) unsigned DEFAULT NULL COMMENT 'The entity revision id this data is attached to, or NULL if the entity type is not versioned',
  `language` varchar(32) NOT NULL DEFAULT '' COMMENT 'The language for this data item.',
  `delta` int(10) unsigned NOT NULL COMMENT 'The sequence number for this data item, used for multi-value fields',
  `field_checklist_status_value` varchar(255) DEFAULT NULL,
  PRIMARY KEY (`entity_type`,`entity_id`,`deleted`,`delta`,`language`),
  KEY `entity_type` (`entity_type`),
  KEY `bundle` (`bundle`),
  KEY `deleted` (`deleted`),
  KEY `entity_id` (`entity_id`),
  KEY `revision_id` (`revision_id`),
  KEY `language` (`language`),
  KEY `field_checklist_status_value` (`field_checklist_status_value`)
) 
ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Data storage for field 7 (field_checklist_status)' |

I am fairly confident that the MySQL command line table structure is the accurate one. This is a Drupal field table.

Does anyone know why there would be a discrepancy?


Solution

  • Could it be that there's both a primary key that has entity_type as a column, and a multiple key that has it as a column? Then the value of Key would be ambiguous, and it would explain the inconsistency.

    The best way to inspect keys in MySQL is to run

    SHOW CREATE TABLE field_data_field_checklist_status;
    

    It will show you the actual keys, with the order of columns within them.