Writing applications that enable users to create and modify tables

You can write a DB2® application that enables users to create new tables, add columns to them, increase the length of columns, rearrange the columns, and delete columns.

Procedure

To create new tables:

  • Use the CREATE TABLE statement.

To add columns or increase the length of columns:

  • Use the ALTER TABLE statement with the ADD COLUMN clause or the ALTER COLUMN clause. Added columns initially contain either the null value or a default value. Both CREATE TABLE and ALTER TABLE, like any data definition statement, are relatively expensive to execute. Also consider the effects of locks.

To rearrange or delete columns:

  • Drop the table and create the table again, with the columns you want, in the order you want. Consider creating a view on the table, which includes only the columns that you want, in the order that you want, as an alternative to redefining the table.