不影响数据的情况下,oracle中将varchar2变成clob类型的语句

    xiaoxiao2022-06-30  182

    //先将需要修改的字段改名进行备份

    alter  table CASE_DOCU_SIX_ORDER_CIACT rename  column  ILLEGAL_FACTS  to  ILLEGAL_FACTS1;

    //新建一个字段,long类型,由varchar2变成 clob需要以long过度 alter  table CASE_DOCU_SIX_ORDER_CIACT add ILLEGAL_FACTS long;

    //复制备份字段的数据到指定字段 update  CASE_DOCU_SIX_ORDER_CIACT set  ILLEGAL_FACTS = ILLEGAL_FACTS1 ;

    //修改指定字段的类型,将long变成clob alter  table  CASE_DOCU_SIX_ORDER_CIACT  modify(ILLEGAL_FACTS clob);

    //修改完毕,删除备份字段即可 alter table CASE_DOCU_SIX_ORDER_CIACT drop COLUMN ILLEGAL_FACTS1;

    或者

    alter table CASE_DOCU_SIX_ORDER_CIACT add ILLEGAL_FACTS1 clob; update CASE_DOCU_SIX_ORDER_CIACT set ILLEGAL_FACTS1 = ILLEGAL_FACTS; alter table CASE_DOCU_SIX_ORDER_CIACT drop column ILLEGAL_FACTS; alter table CASE_DOCU_SIX_ORDER_CIACT rename column ILLEGAL_FACTS1 to ILLEGAL_FACTS;

     


    最新回复(0)