How to change datatype of field in database table from varchar to int? I have created custom table. Now I want to change datatype for a particular column in table. Column name is 'session_number' and its current type is varchar. I want to change it from varchar to int. I used this to do so :

function mymodule_update_7053(&amp;$sandbox) {
  db_change_field('abc', 'session_number', 'session_number', array(
    'type' =&gt; 'int',
    'size' =&gt; '255',
    'not null' =&gt; TRUE,
  ));
  drupal_flush_all_caches();
}


It doesn't change existing type from varchar to int. How to do it please guide.
You must have some error message if the conversion is not accepted.

You first have to validate that this field is not a key or an index. See the db_change_field documentation about this.

After, I think 255 is not a valid value for the size key. The Schema API documentation tell : 


  'size': The data size: 'tiny', 'small', 'medium', 'normal', 'big'.
  This is a hint about the largest value the field will store and
  determines which of the database engine specific datatypes will be
  used (e.g. on MySQL, TINYINT vs. INT vs. BIGINT). 'normal', the
  default, selects the base type (e.g. on MySQL, INT, VARCHAR, BLOB,
  etc.). Not all sizes are available for all data types. See
  DatabaseSchema::getFieldTypeMap() for possible combinations.


And finally, I'm not sure if the DB engine can support the VARCHAR to INT conversion. Then it means your column will be empty and cannot support the 'not null' => TRUE property.

Maybe you have to do this in more than one step.