Change the Content Type of Multiple Nodes Using SQL
1st July 2010
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'.
Questions? Comments? I’m @opdavies on Twitter.
About the Author
Oliver Davies is a Web Developer, System Administrator and Drupal specialist based in the UK. He is a Senior Developer at Microserve and also provides freelance consultancy services for Drupal, Symfony and Laravel applications and Linux servers.