小蹦请进suppose u want to change column a in table t, from varchar(20) to numeric(20) and change its name from a to b,
u can use
ALTER TABLE t CHANGE a b numeric(20);
value in the column will be truncated, if the memory of new type is not big enough to store this value;
As for primary key, if u want to change its type from one to another, u should make sure that there won't be two duplicate value in that column after u do the transformation. otherwise, it will refuse to do the job
不行也。。。
i use: ALTER TABLE t CHANGE a a numeric(20);
got error: All parts of a PRIMARY KEY must be NOT NULL; If you need NULL in a key, use UNIQUE instead..
why? is it because the field 'a' is a primary key?