-Add a temporary Column
Alter table tablename add filedname_temp number (2 );
-Leave the value of the temporary column empty.
Update zyt set id_temp = null; ----- # alter table tablename modify filedname null;
-The field value to be updated is moved to the temporary column, and this column is left empty.
Update tablename set filedname_temp = filedname, filedname = null; commit;
-Change the Data Type of a column to varchar2.
Alter table tablename modify filedname varchar2 (20 );
-Move the temporary column value to the column again, and leave the temporary column empty.
Update tablename set filedname = filedname_temp, filedname_temp = null; commit;
-Delete temporary Columns
Alter table tablename drop column filedname_temp;
-This column cannot be blank.
Alter table tablename modify filedname not null;
-Run the query test.
Select * from tablename;
In this way, you do not need to change the column name or migrate the table. However, the disadvantage is that the table must be updated twice. If the data volume is large, more undo and redo operations are generated on the premise that the operation is stopped. If the operation is not stopped, you can use the online redefinition method.
Note: replace tablename and filedname as your actual values.