Table not creating while installing a custom module in Drupal 7 I am creating a simple module. In that module I need to save the values in a table and I have created an .install file to create the table when the module is installed. 

While installing the module, it is not creating the table and it gives a PDOException Error. I am unable to find the issue with my code.

The error message:


  PDOException: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'unsigned NOT NULL COMMENT ' AMOUNT', rate unsigned NOT NULL COMMENT 'R' at line 3: CREATE TABLE {sampletest} ( id INT unsigned NOT NULL COMMENT 'My unique identifier', amount unsigned NOT NULL COMMENT 'AMOUNT', rate unsigned NOT NULL COMMENT ' RATE', time unsigned NOT NULL COMMENT '  TIME', PRIMARY KEY (id) ) ENGINE = InnoDB DEFAULT CHARACTER SET utf8 COMMENT ' table'; Array ( ) in db_create_table() (line 2717 of H:\xampp\htdocs\drupal7\includes\database\database.inc) ;


Content of the .install file :

&lt;?php
/**
* Implements hook_install().
*/
function sampletest_install() {
 drupal_install_schema('sampletest');
}
/**
* Implements hook_install().
*/
function sampletest_uninstall() {
  drupal_uninstall_schema('sampletest');
}
/**
* Implements hook_schema().
*/

function sampletest_schema() {
  $schema['sampletest'] = array(
    'description' =&gt; t('EMI table'),
    'fields' =&gt; array(
      'id' =&gt; array(
        'description' =&gt; t('My unique identifier'),
        'type' =&gt; 'int',
        'unsigned' =&gt; true,
        'not null' =&gt; true,
      ),
      'amount' =&gt; array(
        'description' =&gt; t('AMOUNT'),
        'type' =&gt; 'bigint',
        'unsigned' =&gt; true,
        'not null' =&gt; true,
      ),
      'rate' =&gt; array(
        'description' =&gt; t('RATE'),
        'type' =&gt; 'bigint',
        'unsigned' =&gt; true,
        'not null' =&gt; true,
      ),
      'time' =&gt; array(
        'description' =&gt; t('TIME'),
        'type' =&gt; 'bigint',
        'unsigned' =&gt; true,
        'not null' =&gt; true,
      ),
    ),
    'primary key' =&gt; array('id'),
  );
  return $schema;     
}
I can see 2 problems with in your code:


You should not call drupal_install_schema() from hook_install() in Drupal 7. hook_schema() will be called and the table will be automatically created/dropped on installing/uninstalling. See here: https://drupal.org/node/224333#install-schema
As @Ollie also stated, there's no field type named bigint. You should use int and set its size to big.


Like following:

'amount' =&gt; array(
  'description' =&gt; t('Amount'),
  'type' =&gt; 'int',
  'size' =&gt; 'big',
  'unsigned' =&gt; TRUE,
  'not null' =&gt; TRUE,
),