In this chapter, we concentrated on the SQL Data Definition Language (DDL). DDL is used to create, modify, and remove database objects. DDL has three main statements: CREATE, ALTER, and DROP. If you want to use a DB2 database, you may need to learn DDL first to create some database objects. A DB2 database has many kinds of objects. Some of them are created by a DB2 command; some, by DDL statements.
We focused primarily on data types, tables, views, and indexes among the database objects created by DDL. A data type is used to specify the attribute of columns in a table. DB2 has two kinds of data types: built-in data types and distinct data types. The data type is a DB2-supplied data type and falls into three main categories: numeric; string, including large object (LOB); and date-time.
The distinct type enables you to create your application-oriented data type based on the built-in data type.
We also looked at DB2 support for Unicode.
A table consists of columns and rows, and stores an unordered set of records. Each column has a data type as one of the attributes. A table itself can have some rules, called constraints, to guarantee the uniqueness of records or to maintain the relationship between and within tables. Constraints help application programmers evaluate the records or maintain the consistency between the tables. A view may also reduce some application development workload. A logical table is created and is based on the physical table or other views. A view can be created to limit access to sensitive data while allowing more general access to other data. An index is one of the most important objects for performance. It can also be used to guarantee the uniqueness of each record. We also covered some of the options in the CREATE and ALTER statements.