Batch assigning a certain category to existing entries I have a few 1000 existing entries and just introduced a new Category type. And I would need to assign all existing entries, to a certain category. 

I've been looking in the MySQL databases what exactly is going on, so I could reproduce it with a query directly in there, but can't seem to pinpoint exactly what I would need to update. 

Any ideas?
You could build a plugin to grab all the entries and then assign that new category to it that way.

This bit of code is untested but this should do it, since this is a one off thing, you can get away with just doing it in chunks by setting the limit and offset, otherwise I'd recommend creating this as a Task:

// get all the entries
$criteria = craft()-&gt;elements-&gt;getCriteria(ElementType::Entry);
$criteria-&gt;section = "news"; // just using news as an example, be sure to set the appropriate section handle
$criteria-&gt;limit = null;
// $criteria-&gt;offset = null; // you could use the limit and offset field to do this 200 at a time, to avoid it timing out on you
$criteria-&gt;status = null;
$entries = $criteria-&gt;find();

$categoryIds = array(222); // this would be the new category (its ID) that you want to assign to the entry, be sure to set the correct ID here

for($i=0; $i&lt;count($entries); $i++)
{
    $entry = $entries[$i]; // for easier reference

    // lets get the existing categories that are assigned to this entry and add it to the new category ID you set a few lines above, if there are no existing categories for this, then you can remove this for loop entirely
    for($c=0; $c&lt;count($entry-&gt;categoryFieldHandle); $c++)
    {
        $categoryIds[] = $entry-&gt;categoryFieldHandle[$c]-&gt;id; // be sure to replace categoryFieldHandle with the category field handle for the category field
    }

    // setting the categories to this field, be sure to replace categoryFieldHandle here too
    $entry-&gt;getContent()-&gt;setAttributes(array(
        'categoryFieldHandle' =&gt; $categoryIds,
    ));

    craft()-&gt;entries-&gt;saveEntry($entry); // save the entry
}