DB2-alter Append/delete/reset column operation 1. add field alter table name add field Name Type demo:1alter Table table_name add Column_test VARCHAR (50); 2. Change field type alter table name alter COLUMN field name set data type type  DEMO: 1ALTER TABLE table_name ALTER COLUMN COLUMN_ Test Set Data type VARCHAR (3); Note: There is an operational limit to changing the field type. To change the field to be larger than the previous type, if you want to make it smaller, you must first drop the original column and then add it again. For example, I want to change a varchar (50) column to varchar (30), so using SQL above is not successful. In addition to different types, you also need to drop the column. 3 first. Remove field alter table Name drop column field name demo: 1alter table table_name Drop Column column_test; Note: After dropping the field, it may cause the table query/insert operation to not be executed, you need to execute the reorg command. reorg table table_name; 4. Add a default value for a Field alter table table name alter COLUMN field name set default value  DEMO: 1ALTER TABLE table_name ALTER COLUMN column_t EST set default ' value '; 5. Add a field with default value demo: 1alter table table_name Add column Column_test Vachar (a) not NULL with default ' value '; 6 . Set field default time is current time Demo: 1alter table table_name ALTER COLUMN COlumn_test set default current date;
Db2-alter Append/delete/Reset column operations