Modify the Data Type of the column corresponding to the primary key of the Oracle database table.
When upgrading our product from SPC100 to SPC200, because the data type of the database table column has changed, you need to write an SQL script to complete the Database Upgrade. Change the id of the primary key column in The T_MOBILE_INDVCONFIG table from varchar2 (100) to number (17 ). You can refer to the following SQL:
-- RENAME the original id column to bak_idALTER TABLE T_MOBILE_INDVCONFIG rename column id TO bak_ID; -- ADD an alter table T_MOBILE_INDVCONFIG ADD id NUMBER (17) COLUMN with the same name as the original COLUMN ); -- convert the Data Type in bak_id and save it to the newly added ID column UPDATE T_MOBILE_INDVCONFIG set id = CAST (bak_ID as number (17 )); -- delete the original alter table T_MOBILE_INDVCONFIG drop column bak_ID; -- set the new COLUMN attribute. In this example, it is set to non-empty alter table T_MOBILE_INDVCONFIG MODIFY (id number (17) not null ); -- re-create the primary key. Because the original primary key has been deleted, if the original ID column has an index, you also need to re-create alter table T_MOBILE_INDVCONFIG add constraint PK_SYS_SMSGATE primary key (ID );