---我想把这个字段变成5位char型的 alter table tb modify str_id(char5);**---这个不行,小变大可以,大变小不行!---OK! select right(str_id,5) from tb
另一种操作思路:1.增加一新列 alter table temp_q add b varchar2(5) 2.更新列 update temp_q set b= substr(a,2,5) 3.去掉旧列 alter table temp_q drop column a 4.重命名新列 alter table temp_q rename column b to a
相关的操作: 增加一列 alter table tb add a varchar2(20); 修改一列字段大小 alter table tb modify a varhcar2(10); 去掉一列 alter table tb drop column a; 重新命名一列 alter table tb rename column b to a;
alter table tb modify str_id(char5);
---我想变成5位之后,第一位的0去掉,后面的5位还想保留
select ritht(str_id,5) from tb
但是执行第一句alter table tb modify str_id(char5);之后
数据没有损失么,本来6位现在变成了5位第二句不是select查询语句么,数据都已经损失了,在查还查的到么
alter table tb modify str_id(char5);**---这个不行,小变大可以,大变小不行!---OK!
select right(str_id,5) from tb
alter table temp_q add b varchar2(5)
2.更新列
update temp_q set b= substr(a,2,5)
3.去掉旧列
alter table temp_q drop column a
4.重命名新列
alter table temp_q rename column b to a
增加一列
alter table tb add a varchar2(20);
修改一列字段大小
alter table tb modify a varhcar2(10);
去掉一列
alter table tb drop column a;
重新命名一列
alter table tb rename column b to a;