Modify the Data Type of a table field in ORACLE

Source: Internet
Author: User

To modify the Data Type of a table field in ORACLE, you need to use a backup field to change the table as follows:

Alter table tablename alter column colname newDataType

 

For example:
Alter table mytable alter column mycol1 int default 0

 

Later, I implemented it. I checked the information and said this (or not ):
Alter table userreg modify column bak2 VARCHAR2 (20) default to_char (sysdate, 'yyyy-MM-DD HH24: MI: ss ')

 

After practice, Oracle had to change it like this (and ensure that the column has no data; otherwise, it cannot be changed ):
Alter table userreg modify (bak2 varchar2 (26) default to_char (sysdate, 'yyyymmddhh24miss '))

 

Or:
Alter table userreg modify (bak2 char (21) default to_char (current_date, 'yyyy-MM-DD HH24: MI: ss '))

 


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.