深入浅出mysql第5zhang
alter
alter tabel tablename add:新加列
alter table tablename rename to:改变表名字
alter table tablename change cloumn 原名 新的名字及属性(属性不一定全部出现,名字一定要出现)
alter table tablename modify cloumn 名字 属性
//修改属性,如vchar(10)到char(1)会发生截断
change 和modify的区别:change用于修改列明,也可以修改属性,修改属性时,需要加上新的列名,如:change cloumn a a char(1) 列名没变
modify修改属性
alter table tablename drop clume 名字:删除列
新的列属性:first ,last ,after 列名,before l列名,third,second..
实列:
location列,值的格式均为:镇名,村名 村名均为2字节
根据原子性原子,则需要把location换成两列,city和village
1.新建两列 alter table tablename add cloumn city ...,
....
2.填数据
update tabename set village = right(location, 2) right字符串操作函数,很多类似的函数,right取右边2字节
update tabename set city= substring(location, ',', 1) 取第一个,前的字符串
浙公网安备 33010602011771号