How to create db table while installing a module? I want to create a table in Drupal while installing a module (custom module which is crated by me). I tried in the below way, but I could not able to create a table in Drupal db. what am I missing, what else I have to do?

function custom_agent_handler_install() {

if (!db_table_exists('demo_score')) {
  $demo_score_schema = array(
    'description' =&gt; 'To store unique number and other details.',
    'fields' =&gt; array(
      'score'    =&gt; array('type' =&gt; 'int', 'unsigned' =&gt; TRUE, 'not null' =&gt; TRUE),
      'timestamp' =&gt; array('type' =&gt; 'int', 'unsigned' =&gt; TRUE, 'not null' =&gt; TRUE, 'default' =&gt; '0'),
    ),
  );

return $demo_score;
}


}
You should implements hook_schema() in your modulename.install file. In druapl 7, you do not need to use hook_install to create database table. 


  A Drupal schema definition is an array structure representing one or
  more tables and their related keys and indexes. A schema is defined by
  hook_schema() which must live in your module's .install file.


Code Snippets:

/**
 * Implements hook_schema() 
 */

function custom_travel_api_schema() {

  $schema['custom_booking'] = array(
    'description' =&gt; 'To store the booking flight.',
    'fields' =&gt; array(
      'bid' =&gt; array(
       'type' =&gt; 'serial',
        'unsigned' =&gt; TRUE,
        'not null' =&gt; TRUE,
        'description' =&gt; 'The booking id.',        
      ),
      'source' =&gt; array(
        'type' =&gt; 'varchar',
        'length' =&gt; '255',
        'description' =&gt; 'The source city for the booking.',
      ),
      'destination' =&gt; array(
        'type' =&gt; 'varchar',
        'length' =&gt; '255',
        'description' =&gt; 'The destination city for the booking.',
      ),
      'bdate' =&gt; array(
        'type' =&gt; 'int',
        'not null' =&gt; TRUE,
        'default' =&gt; 0,        
        'description' =&gt; 'The date of the booking',
      ),
      'amount' =&gt; array(
        'type' =&gt; 'int',
        'not null' =&gt; TRUE,
        'default' =&gt; 0,        
        'description' =&gt; 'The amount of the booking',
      ),
      'status' =&gt; array(
        'type' =&gt; 'int',
        'not null' =&gt; TRUE,
        'default' =&gt; 0,        
        'description' =&gt; 'The status of the booking(0 -&gt; In process, 1 -&gt; completed)',
      ),
      'uid' =&gt; array(
        'type' =&gt; 'int',
        'not null' =&gt; TRUE,
        'default' =&gt; 0,        
        'description' =&gt; 'The user id of the booking',
      ),
    ),
    'primary key' =&gt; array('bid'),
  );

  return $schema;

}


You can check this for more reference.