-2

Im trying to rename a column in one of my tables but MySQL returns me this error:

ERROR 1064 (42000): 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 'COLUMN IPorigen TO IPorig' at line 1

This is the statement I tried using to rename the column:

ALTER TABLE InformeGeneral RENAME COLUMN IPorigen TO IPorig;

I have also tried this too:

sp_RENAME 'InformeGeneral.IPorigen' , 'IPorig' , 'COLUMN';

I don't know what I'm doing wrong?
My MySQL version is: mysql Ver 14.14 Distrib 5.5.41, for debian-linux-gnu (i686) using readline 6.2

AeroX
  • 3,387
  • 2
  • 25
  • 39

4 Answers4

0

Thats not a valid statement It should be as

alter table table_name change col_name new_col_name datatype

http://dev.mysql.com/doc/refman/5.0/en/alter-table.html

SO in your case it should be as

ALTER TABLE InformeGeneral change IPorigen IPorig;
Abhik Chakraborty
  • 44,654
  • 6
  • 52
  • 63
0

Try to read this. Error renaming a column in MySQL

Probaly you need to add the datatype of your column

Community
  • 1
  • 1
Galma88
  • 2,398
  • 6
  • 29
  • 50
0

Use this syntax to rename your column:

ALTER TABLE InformeGeneral CHANGE IPorigen IPorig datatype(length)

Replace datatype with INT, VARCHAR or whatever you need for that column.

Galma88
  • 2,398
  • 6
  • 29
  • 50
0

Try this ( Assuming type of IPorigen is varchar ):

ALTER TABLE InformeGeneral change COLUMN IPorigen  IPorig varchar(30);
dsharew
  • 10,377
  • 6
  • 49
  • 75