Is it possible to detect access to table on site db table and redirect the db query to a db shared by multiple websites?
You don't need to intercept all the query done for a database table. It is enough you change the settings for the database in the settings.php file.

Suppose that the default database definition is the following one.

$databases['default']['default'] = array(
  'driver' =&gt; 'mysql',
  'database' =&gt; 'databasename',
  'username' =&gt; 'username',
  'password' =&gt; 'password',
  'host' =&gt; 'localhost',
  'collation' =&gt; 'utf8_general_ci',
);


If you change it as follow, you change the database used for that particular table.

$databases['default']['default'] = array(
  'driver' =&gt; 'mysql',
  'database' =&gt; 'databasename',
  'username' =&gt; 'username',
  'password' =&gt; 'password',
  'host' =&gt; 'localhost',
  'prefix' =&gt; array(
    'oauth2_server_client' =&gt; 'otherdatabase.',
  ),
  'collation' =&gt; 'utf8_general_ci',
);


In this way, you are telling Drupal that for the oauth2_server_client table, the otherdatabase database needs to be used. That database needs to be accessible from the same database user (username, in my example).

Generally speaking, you can alter the query done from a module if:


The query is a dynamic query
The module added a tag to that query, such as in the following code

$query = db_select('node', 'n')
  -&gt;addTag('node_access');



In that case, you could implement hook_query_alter() or hook_query_TAG_alter().

In your case, since you want to change the database table used for all the queries to that table, I would change the database definition in the settings.php file.