Change the Content Type of Multiple Nodes Using SQL
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'.
Was this useful?
About me
I'm an Acquia-certified Drupal Triple Expert with 17 years of experience, an open-source software maintainer and Drupal core contributor, public speaker, live streamer, and host of the Beyond Blocks podcast.