How to create a table without uninstalling and reinstalling the module? I have a module and an installation file that is used to create a table.

According to my requirement, I need to add an another table in the same install file. I know that by using hook_schema() we can create n number of tables.
But we need to uninstall and reinstall again to create the tables. If I use this, my existing data will be lost, so I am not supposed to do this.

Is there any way to create a table without uninstalling and reinstalling the module?
This link answered my question: Updating tables: hook_update_N() functions.

For example:

In Drupal 7:

&lt;?php
/**
 * Create new database table {mytable2}.
 */
function mymodule_update_7101() {
  $schema['mytable2'] = array(
     // table definition array goes here
  );
  db_create_table('mytable2', $schema['mytable2']);
}
?&gt;


and in Drupal 6:

&lt;?php
/**
 * Create new database table {mytable2}.
 */
function mymodule_update_6101() {
  $schema['mytable2'] = array(
     // table definition array goes here
  );
  $ret = array();
  db_create_table($ret, 'mytable2', $schema['mytable2']);
  return $ret;
}
?&gt;