This post is for myself. I usually like to change database and forget the commands. So this is a reference sheet for me while dealing with my WordPress database.
There usually are 11 default tables – with “wp_” prefix.
wp_options is the one I usually deal with while changing the directory, website address and so on.
RENAME TABLE old_posts TO wp_posts;
Merging two tables (when I manually merge posts from two separate blogs. )
CREATE TABLE wp_post_merged SELECT DISTINCT * FROM (SELECT * FROM wp_post_1 UNION ALL SELECT * FROM wp_post_2) sq;
Replacing a text string in a table
UPDATE table_name SET column_name = replace(column_name, 'DeleteThis', 'AddThis');
UPDATE wp_posts SET post_content = replace(post_content, 'Apple computers', 'MS computers');