Creating and modifying Db2 objects from application
programs
Your application program can create and manipulate Db2 objects, such as tables, views,
triggers, distinct types, user-defined functions, and stored procedures.
You must have the appropriate authorizations to create such objects.
Creating tables from application programs
Creating a table provides a logical place to store related data on a Db2 subsystem.
Providing a unique key for a table
If a table that has no unique column values, you can provide a unique identifier by using ROWID columns or identity columns to store unique values for each row in a table.
Fixing tables with incomplete definitions
If a table has an incomplete definition, you cannot load the table, insert data, retrieve data, update data, or delete data. You can however drop the table, create the primary index, and drop or create other indexes.
RENAME TABLE in a table maintenance scenario
The RENAME TABLE statement is useful when you need to temporarily take a table offline for maintenance that involves structural changes to the table. Applications can continue to run against another copy of the table until maintenance is complete.
Dropping tables
When you drop a table, you delete the data and the table definition. You also delete all synonyms, views, indexes, referential constraints, and check constraints that are associated with that table.
Defining a view
A view is a named specification of a result table. Use views to control which users have access to certain data or to simplify writing SQL statements.
Dropping a view
When you drop a view, you also drop all views that are defined on that view. The base table is not affected.
Creating a common table expression
Creating a common table expression saves you the overhead of creating and dropping a regular view that you need to use only once. Also, during statement preparation, Db2 does not need to access the catalog for the view, which saves you additional overhead.
Creating a trigger
A trigger is a set of SQL statements that execute when a certain event occurs in a table or view. Use triggers to control changes in Db2 databases. Triggers are more powerful than constraints because they can monitor a broader range of changes and perform a broader range of actions. This topic describes support for advanced triggers.
Sequence objects
A sequence is a user-defined object that generates a sequence of numeric values according to the specification with which the sequence was created. Sequences, unlike identity columns, are not associated with tables. Applications refer to a sequence object to get its current or next value.
Db2 object relational extensions
With the object extensions of Db2 , you can incorporate object-oriented concepts and methodologies into your relational database by extending Db2 with richer sets of data types and functions.
Creating a distinct type
Distinct types are useful when you want Db2 to handle certain data differently than other data of the same data type. For example, even though all currencies can be declared as type DECIMAL, you do not want euros to be compared to Japanese yen.
Creating a user-defined function
You can extend the SQL functionality of Db2 by adding your own or third party vendor function definitions.
Creating stored procedures
A stored procedure is executable code that can be called by other programs. The process for creating one depends on the type of procedure.