0

How to change the type of a column in SQL. For example the current type is char(2) I would like to make it char(20)?

ALTER TABLE test
ALTER COLUMN name char(20)  
user3066588
  • 111
  • 1
  • 7
  • 2
    search first :) http://stackoverflow.com/questions/1356866/how-do-i-change-the-data-type-for-a-column-in-mysql – M.chaudhry Apr 22 '14 at 22:09
  • sorry I did not know what to search exactly for.. thank you for your suggestions – user3066588 Apr 22 '14 at 22:19
  • As a note, normally you would want `varchar()` rather than `char()`, unless you know the column consists of codes that are all exactly the same length (such as state abbreviations or airport codes). – Gordon Linoff Apr 22 '14 at 22:49

1 Answers1

1

for MySql try:

ALTER TABLE test
MODIFY COLUMN name char(20)
Daniel Shalev
  • 331
  • 3
  • 10