Have module .install create a table in a non-default DB I have constructed a module that, using the .install file, creates a table on a database different than the default.  The module installs fine and functions fine – just a hello world example in the controller. However, when I uninstall the module I get: “The website encountered an unexpected error. Please try again later.” and the reports log there is: 
DatabaseExceptionWrapper: SQLSTATE[42S02]...

Here is the .install file code: 

function hello_world_schema()
{
    db_set_active('notTheDefaultDB');
    $schema['create_table'] = array(
      'fields' =&gt; array(
        'id' =&gt; array('type' =&gt; 'serial', 'not null' =&gt; TRUE,),
        'name' =&gt; array('type' =&gt; 'varchar', 'length' =&gt; 40, 'not null' =&gt; TRUE,),
        'last_name' =&gt; array('type' =&gt; 'varchar', 'length' =&gt; 40, 'not null' =&gt; TRUE,),
        'message' =&gt; array('type' =&gt; 'varchar', 'length' =&gt; 250, 'not null' =&gt; TRUE,),
        'boogie' =&gt; array('type' =&gt; 'varchar', 'length' =&gt; 20, 'not null' =&gt; TRUE,),
      ),
      'primary key' =&gt; array('id'),);
    return $schema;
}


I do realize that I'm tell hook_schema to switch to notTheDefaultDB and don’t switch it back – if it is switched before the return statement the table is created in the default.

As I said, the module seems to function as intended, but blows up when uninstalled.

Is there a way to write the module so it doesn’t blow up on uninstall or perhaps an entirely different way to do what I’m after?
To my mind, the entire purpose of hook_schema is to build the Drupal schema. If you need/want to create tables outside of Drupal, it seems like just using PDO in a hook_install() and hook_uninstall() implementation might be the way to go. Can you explain your use case a little bit more?

All that said, I don't see an obvious reason for your code to fail.