Change the Content Type of Multiple Nodes Using SQL
1st July 2010
Warning: This post is over a year old. I don't always update old posts with new information, so some of this information may be out of date.
In this post, I will be changing values within my Drupal 6 site's database to quickly change the content type of multiple nodes. I will be using a test development site with the core Blog module installed, and converting Blog posts to a custom content type called 'News article'.
Before changing any values within the database, ensure that you have an up-to-date backup which you can restore if you encounter a problem!
To begin with, I created the 'News article' content type, and then used the Devel Generate module to generate some Blog nodes.
Using an SQL 'Update' command, I can change the type value from 'blog' to 'article'. This will change every occurance of the value 'blog'. If I wanted to only change certain nodes, I could add a 'Where' clause to only affect nodes with a certain nid or title.
Now, when I query the database, the type is shown as 'article'.
Now, when I go back into the administration section of my site and view the content, the content type now shows at 'News article'.
About the Author
Oliver Davies is a full-stack Web Developer and System Administrator based in the UK. He is a Senior Developer at Microserve and a part-time freelancer specialising in Drupal, Symfony and Laravel development and Linux systems administration.