Oracle modifies the data type of an existing column

Source: Internet
Author: User

Oracle cannot modify the data type of an existing column if there is data in the table. However, you can create a temporary column, copy the data of the column to the temporary column, delete the original column, and modify the name of the temporary column. In this case, it seems a bit confusing. Let's explain it step by step. The table "AC_REG" has a column: is_active, which is originally of the character type. The goal is to change it to the numerical type.

--- Change IS_ACTIVE to numeric. -- add an alter table AC_REG add is_active_temp number (1); -- change the value of IS_ACTIVE, assign is_active_tempupdate AC_REG set is_active_temp = cast (is_active as number (1); -- delete the original alter table AC_REG drop column is_active; -- modify the name alter table AC_REG rename column is_active_temp to is_active;

 


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.