南京的电商网站设计,seo基础知识考试,南海网站建设,网站建设如何选择良好的服务器对mysql的表的表结构进行修改时#xff0c;有用到change#xff0c;modify两个#xff0c;它们都有“改变”的意思#xff0c;那它们在功能上有什么区别了#xff1f;做个试验比较下1、字段重命名#xff1a;1)changemysql alter table t1 change number id char(2);…对mysql的表的表结构进行修改时有用到changemodify两个它们都有“改变”的意思那它们在功能上有什么区别了做个试验比较下1、字段重命名1)changemysql alter table t1 change number id char(2);Query OK, 0 rows affected (0.08 sec)Records: 0 Duplicates: 0 Warnings: 02)modifymysql alter table t1 modify id num int(2);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 num int(2) at line 1mysql结论能用change重命名而modify不能。2、修改字段类型和约束1)modifymysql alter table t1 modify id int(2);Query OK, 0 rows affected (0.06 sec)Records: 0 Duplicates: 0 Warnings: 0mysql alter table t1 modify id int(2) not null;Query OK, 0 rows affected (0.08 sec)Records: 0 Duplicates: 0 Warnings: 02)changemysql alter table t1 change id char(2);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 char(2) at line 1mysql alter table t1 change id char(2) not null;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 char(2) not null at line 1结论modify能修改字段类型和约束而change不能。最终结论change用来字段重命名不能修改字段类型和约束modify不用来字段重命名只能修改字段类型和约束