One, ALTER TABLE name modify field type (word length);
If not, use the second method:
Two
--Create tablecreate table TABLE1 ( col1 Number (9), col2 char (20));//attempt to modify ALTER TABLE TABLE1 MODIFY COL1 Number (10 ); --Modification succeeds because there is no data in the table//INSERT data INSERT INTO TABLE1 (COL1, COL2) VALUES (1, ' AAA ');//try again to modify alter TABLE TABLE1 MODIFY COL2 VARCHAR2 (20); --Modification failed because there is already data in the table, do not allow direct operation//cache tables CREATE TABLE T_table1 as SELECT * from table1;//delete the original table all data delete from table1;//modify field alter Table TABLE1 MODIFY COL1 number (9);--Modify success alter TABLE TABLE1 MODIFY COL2 VARCHAR2 (20);--Modify success//INSERT raw data inserts into TABLE1 Selec T * FROM t_table1;//Delete cache table drop table t_table1;//Note that if it is a char type, the number of bits is automatically padded with spaces, so use the char type with caution and trim () to verify that there are qualifying records. When the initial table structure, SELECT * from TABLE1 WHERE COL2 = ' aaa '; Is no data, requires SELECT * from TABLE1 WHERE TRIM (COL2) = ' AAA ';
Oracle database tables already have data, want to modify the type of a field, how to modify