Oracle Modify field Type method summary

Source: Internet
Author: User

SQL Code
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21st
22
23
24
25
There is a table named TB, field segment named Name, data type nchar ( -).

1. Assuming that the field data is empty, you can do it directly, regardless of the field type you are changing to:
Alter TableTBModify(name Nvarchar2 ( -));

2. If the field has data, change to NVARCHAR2 ( -) can be executed directly:
Alter TableTBModify(name Nvarchar2 ( -));

3. If the field has data, change to VARCHAR2 ( +) will pop up when executed: "Ora-01439: To change the data type, the column you want to modify must be empty, and the following method is used to resolve the problem:


Alter TableTBRename columnname toname_tmp;


Alter TableTBAddnamevarchar2( +);


UpdateTBSetname=Trim(NAME_TMP);


Alter TableTBDrop columnname_tmp;

Summarize:
1, when the field has no data, or to modify the new type and the original type is compatible, you can directly modify modification.
2. When the field has data and is incompatible with the new type and the original type to be modified, create a new field to transfer indirectly.

Oracle Modify field Type method summary

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.