oracle varchar2改成大字段类型clob,读取大字段内容

oracle varchar2(4000)改成大字段类型clob,如果需要改成大字段的varchar2列有内容,不能直接用

 

alter table med_generic modify option07 blob;

直接用上面的会提示:ORA-22858: 数据类型的变更无效

因此,修改应采用下面的方法:

 

--增加大字段项
alter table med_generic add hehe clob;
--将需要改成大字段的项内容copy到大字段中
update med_generic set hehe=option07;
--删除原有字段
alter table med_generic drop column option07;
--将大字段名改成原字段名
alter table med_generic rename column hehe to option07;
此时原option07的内容都到新建的hehe(clob类型),且原option07字段删除了,hehe字段名称改为option07字段

直接查询:

 

select g.option07 from med_generic g where g.medname='amxl';

若要直接查出大字段的内容,可将sql改为:

 

select dbms_lob.substr(g.option07) from med_generic g where g.medname='amxl';

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值