Oracle modifies the column type. oracle modifies the column type.
1. If the field data is empty, you can directly execute the following command regardless of the field type:
Alter table tb modify (name nvarchar2 (20 ));
2. If the field has data, you can change it to nvarchar2 (20) and execute it directly:
Alter table tb modify (name nvarchar2 (20 ));
3. If the field has data, it will pop up when it is changed to varchar2 (40) Execution: "ORA-01439: to change the data type, the column to be modified must be blank ", the following method is used to solve the problem:
/* Change the original field name to name_tmp */
Alter table tb rename column name to name_tmp;
/* Add a field name with the same name as the original field name */
Alter table tb add name varchar2 (40 );
/* Update the original field name_tmp to the added field name */
Update tb set name = trim (name_tmp );
/* After the update, delete the original field name_tmp */
Alter table tb drop column name_tmp;
Summary:
1. When the field does not have data or the new type to be modified is compatible with the original type, you can directly modify it by modify.
2. When a field has data and is incompatible with the original type, it is required to create a new field indirectly for transfer.