PDA

View Full Version : Recreate table


chikuru
04-23-2017, 05:49 PM
Database error in vBulletin 4.2.2:

Invalid SQL:

INSERT INTO taggregate_temp_1492976820
SELECT threadid, COUNT(*) AS views
FROM threadviews
GROUP BY threadid;

MySQL Error : Can't find file: 'threadviews' (errno: 2)

Whats the query to recreate that table in vbulletin 4.2?
Thanks!

Paul M
04-23-2017, 06:57 PM
You can get it from the mysql-schema.php file, in the install folder.

chikuru
04-24-2017, 01:28 AM
Thanks!

The missing threadviews table caused the database to create lots of taggregate_temp_xxxx tables.
Is there sql query to delete them all at once? Because I cant manually delete them because phpmyadmin hangs when I tried to load the database. Thanks!

Andreas
04-24-2017, 03:48 PM
Unfortuatenly, there is no way to delete all those tables with one query.

You could do some trickery with information_schema though:
http://stackoverflow.com/questions/1589278/sql-deleting-tables-with-prefix

Alternatively you could run a simple script:

require('./global.php');

$tables = $db->query_read("SHOW TABLES LIKE 'taggregate\_temp\__%'");
while ($table = $db->fetch_row($tables))
{
$db->query_write("DROP TABLE `$table[0]`");
}


No guarantees whatsoever, eg. you should be prepared to have a backup ready if anything goes wrong :)

chikuru
04-25-2017, 10:21 AM
Thanks Andreas! Problem solved :)
More than 100,000 temp tables have been removed :D