3

The full warning message goes like this: PDOException: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'mysite_drupal.cache_views' doesn't exist: TRUNCATE {cache_views} ; Array ( ) in cache_clear_all() (line 165 of /home/user/mysite.com/includes/cache.inc). should I try to manually create it?

closed as off-topic by kiamlaluno Jul 8 '14 at 6:55

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question was caused by a problem that can no longer be reproduced, was solved by a cache clear, or was a simple typographical error. While similar questions may be on-topic here, this one was resolved in a manner unlikely to help future readers." – kiamlaluno
If this question can be reworded to fit the rules in the help center, please edit the question.

  • Have you checked to see if the table exists in mysql? – mister koz Feb 17 '14 at 0:41
3

Yes, if cache_views is missing and you have the Views module installed, you need to create it.

To do so, simply duplicate the standard cache table and rename it to cache_views; they share the same columns.

You might also need to re-create the cache_views_data table, also with the same columns.

  • as always, great ;) – Yusef Feb 17 '14 at 9:15
2

From a mysql command prompt, you can go

show create table cache;

That will show the create table syntax for a cache table.

Change the table name to cache_views and you can use that SQL to recreate the table.

For example:

CREATE TABLE `cache_views` (
  `cid` varchar(255) NOT NULL DEFAULT '' COMMENT 'Primary Key: Unique cache ID.',
  `data` longblob COMMENT 'A collection of data to cache.',
  `expire` int(11) NOT NULL DEFAULT '0' COMMENT 'A Unix timestamp indicating when the cache entry should expire, or 0 for never.',
  `created` int(11) NOT NULL DEFAULT '0' COMMENT 'A Unix timestamp indicating when the cache entry was created.',
  `serialized` smallint(6) NOT NULL DEFAULT '0' COMMENT 'A flag to indicate whether content is serialized (1) or not (0).',
  PRIMARY KEY (`cid`),
  KEY `expire` (`expire`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Generic cache table for caching views...'

You can also create the table in PHP with something similar to:

$schema['cache_views'] = drupal_get_schema_unprocessed('system', 'cache');
db_create_table('cache_views', $schema['cache_views']);

You may also need to recreate cache_views_data in a similar way.

  • Thanks, that got it. Why do you think those tables wouldn't be there though? – Ed523 May 16 '14 at 3:14

Not the answer you're looking for? Browse other questions tagged or ask your own question.