ALTER TABLE table_name ALTER COLUMN column_name datatype

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Lyndeen
    New Member
    • Sep 2010
    • 1

    #1

    ALTER TABLE table_name ALTER COLUMN column_name datatype

    I want to alter the datatype of a column in a table.
    The query i used:

    ALTER TABLE my_persons alter COLUMN City int

    but it is showing an error:
    Error Code : 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 'int' at line 1

    Execution Time : 00:00:00:000
    Transfer Time : 00:00:00:000
    Total Time : 00:00:00:000
  • Oralloy
    Recognized Expert Contributor
    • Jun 2010
    • 988

    #2
    Lyndeen,

    What are you trying to do?

    This is a link to the MySQL 5.1 ALTER TABLE manual page.

    Hopefully it helps.

    Comment

    • JKing
      Recognized Expert Top Contributor
      • Jun 2007
      • 1206

      #3
      Try
      Code:
      ALTER TABLE my_persons MODIFY City int
      ALTER COLUMN is used to change the default setting of a column.
      MODIFY COLUMN is for changing the data type.
      CHANGE COLUMN is for renaming and or changing the data type.

      The keyword COLUMN is optional in the statement.

      Comment

      Working...