1. Set this column to null and modify its type (this will result in data loss). 2. simplest method: assume that your table name is tab_targetcreatetabletestasselect.
1. Set this column to null and modify its type (this will result in data loss). 2. simplest method: assume that your table name is tab_target create table test as select.
1. Set this column to null and modify its type (this will cause data loss)
2. The simplest method:
Assume that your table is named tab_target.
Create table test as select * from tab_target whre 1 = 2;
Alter table test modify (col_name number (5 ));
Insert into test select * from tab_target;
Drop table tab_target;
Rename test to tab_target;
3. (idea: Rename the field name of the type to be changed to backup, add a field with the same name as the field name of the type to be changed (the original field has been renamed), and then update the data, finally, delete the renamed backup field)
/* Modify the original field name */
Alter table name rename column field name TO field name 1;
/* Add a field with the same name as the original field */
Alter table name ADD field name VARCHAR2 (30 );
/*
Update the original data to a new field.
Note that data type conversion must be performed on the display (different from MSSQL)
*/
UPDATE table name SET field name = CAST (field name 1 AS VARCHAR2 (30 ));
/* Delete the original backup field */
Alter table Name drop column field name 1;
For more information about Oracle, see the Oracle topic page? Tid = 12