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 Sequel Pro, I can query the database to view the Blog posts (you can also do this via the Terminal in a Mac OS X/Linux, Oracle SQL Developer on Windows, or directly within phpMyAdmin):

Using an SQL 'Update' command, I can change the type value from 'blog' to 'article'. This will change every occurrence 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'.