The change the definition of a db column, the query below can be used for example, if we have this db schema
users (
firstname varchar(20),
lastname varchar(20),
age char(2)
)
To change the type of age
column from char
to int
, we use the query below:
ALTER TABLE users CHANGE age age tinyint UNSIGNED NOT NULL;
General format is:
ALTER TABLE table_name CHANGE column_name new_column_definition