Oracle field (primary key) type modification method for processing existing data

Source: Internet
Author: User

  1. From me Oracle Latest SQL Recall Walkthrough 11 blog post http://blog.csdn.net/luozhonghua2014/article/details/45729669
  2. Just re-publish once, is to extract experience, so that we can find a solution


  3. --------Modify the field type of the existing data (the first 4 steps will cause the constraint in the table to be lost)  --1 rename field  ALTER TABLE example rename column ID to Sid;  --2 Add ID field  ALTER TABLE example add ID varchar2 ($);    --3 Updating Data Update  example set id = SID;  --4 Delete the backup data field  ALTER TABLE example drop column SID;  --5 new constraint  ALTER TABLE example ADD constraint exmaple_id primary key (ID);  -----------------------------add constraint--------------------------------------  ALTER TABLE example add Unique (age);  ALTER TABLE example drop unique (age);  --Lookup Table uniqueness constraints (including name, constituent columns)  Select column_name from    user_cons_columns cu, user_constraints au   where Cu.constraint_name = Au.constraint_name and     cu.table_name = ' example ';  

Oracle field (primary key) type modification method for processing existing data

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.