views:

53

answers:

2

Hi all, I'm working with the mediawiki API ( e.g. http://en.wikipedia.org/w/api.php) and I would like to be able to 'truncate' the mysql tables in order to reset the local installation while keeping some tables (users, ?...). What would be the SQL queries ?

I would say: tuncate all the tables but ${PREFIX}_user and update ${PREFIX}_user set user_editcount=0 ?

Any other(safer) suggestion ?

A: 

get list of tables from your database:

echo "show tables;" | mysql -u user_name -p db_name > tables

determine which tables you want to truncate, then create an sql script

TRUNCATE TABLE a;
TRUNCATE TABLE b;
update <prefix>user set user_editcount=0;

then run it through the client:

mysql -u user_name -p database_name < truncate-all.sql
Evgeny
Your answer doesn't tell me *which* tables of mediawiki should be truncated.
Pierre
just use "show tables;" in mysql to extract the list
Evgeny
+1  A: 

The correct answer was posted on the MediaWiki mailing list: see http://lists.wikimedia.org/pipermail/mediawiki-l/2009-October/032322.html

Pierre