当前位置:首页 > 数据库 > Oracle

oracle处理已有数据的字段(主键)类型修改方法

  •   只所以重新发布一次,就是抽取经验,让大家可以找到解决方法


  • --------处理已有数据的字段类型修改(前4步操作会使表中的约束丢失)  
    --1重命名字段  
    alter table example rename column id to sid;  
    --2添加id字段  
    alter table example add id varchar2(200);    
    --3更新数据  
    update example set id = sid;  
    --4删除备份数据的字段  
    alter table example drop column sid;  
    --5新增约束  
    alter table example add constraint exmaple_id primary key(id);  
    -----------------------------add constraint--------------------------------------  
    alter table example add unique(age);  
    alter table example drop unique(age);  
    --查找表的唯一性约束(包括名称,构成列)  
    select column_name  
      from user_cons_columns cu, user_constraints au  
     where cu.constraint_name = au.constraint_name  
       and cu.table_name = 'example';  

  • oracle处理已有数据的字段(主键)类型修改方法

    标签:oracle sql

    本文系统来源:http://blog.csdn.net/luozhonghua2014/article/details/46489531


    【说明】本文章由站长整理发布,文章内容不代表本站观点,如文中有侵权行为,请与本站客服联系(QQ:254677821)!

    相关教程推荐

    其他课程推荐