Modify a non-empty table field type Oracle

Source: Internet
Author: User

Execute the following statement "to modify the data type, the column you want to change must be empty"
ALTER TABLE name modify (Target Field VARCHAR2 (100));

Steps to resolve:

The first step is to add a temporary field to the table
ALTER TABLE name add temporary field the original type of the Target field;

The second step, the value of the target field is paid to the temporary field, and the Target field is empty
Update table Name set TEMP field = Target Field, Target Field =null;

Step three, modify the target type
ALTER TABLE name modify Target Field VARCHAR2 (100);

Fourth, the value of the temporary field is paid to the target field, and the temporary field is placed empty
Update table name set Target Field = Temp field, temporary field =null;

Last step, delete temporary fields
ALTER TABLE Name drop column temp field;

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.