原文:https://blog.csdn.net/DaneLei/article/details/87986131
修改字段名语法:alter table tableName rename column oldCName to newCName;
例:alter table student rename column address to addr
添加字段的语法:alter table tablename add (column datatype [default value][null/not null],….);
例:alter table student add( grade number(3) default 99 not null) ;
修改字段的语法:alter table tablename modify (column datatype [default value][null/not null],….);
例:alter table student modify(grade varchar2(5));
删除字段的语法:alter table tablename drop (column);
例:alter table student drop (grade);
※如果修改字段是字符串转数值且原来有数据等其他特殊情况,可以建临时字段过渡
/*修改原字段名grade为grade_tmp*/
alter table student rename column grade to grade_tmp;
/*增加一个和原字段名同名的字段grade*/
alter table student add grade number(3);
/*将原字段grade_tmp数据更新到增加的字段grade*/
update student set grade=trim(grade_tmp);
/*更新完,删除原字段grade_tmp*/
alter table student drop column grade_tmp;
来源:oschina
链接:https://my.oschina.net/u/4274358/blog/4329682