Data definition language (DDL) describes the portion
of SQL that allows you to create, alter, and destroy database objects. These
database objects include schemas, tables, views, sequences, catalogs, indexes,
and aliases.
Create a schema
A schema provides a logical grouping of SQL objects.
Create a table
A table can be visualized as a two-dimensional arrangement of data consisting of rows and columns.
Create a table using LIKE
You can create a table that looks like another table. That is, you can create a table that includes all of the column definitions from an existing table.
Create a table using AS
The CREATE TABLE AS statement creates a table from the result of a SELECT statement.
Create and alter a materialized query table
A materialized query table is a table whose definition is based on the result of a query. As such, the materialized query table typically contains precomputed results based on the data existing in the table or tables that its definition is based on.
Declare a global temporary table
You can create a temporary table for use with your current session using the DECLARE GLOBAL TEMPORARY TABLE statement.
Create and alter an identity column
Every time that a new row is added to a table with an identity column, the identity column value in the new row is incremented (or decremented) by the system.
Use ROWID
Using ROWID is another way to have the system assign a unique value to a column in a table. ROWID is similar to identity columns, but rather than being an attribute of a numeric column, it is a separate data type.
Create and use sequences
A sequence is an object that allows you to generate values quickly and easily.
Create descriptive labels using the LABEL ON statement Sometimes the table name, column name, view
name, index name, sequence name, alias name, or SQL package name does not
clearly define data that is shown on an interactive display of the table.
You can create a more descriptive label for these names by using the LABEL
ON statement.
Describe an SQL object using COMMENT ON After you create an SQL object such as a table,
view, index, package, procedure, parameter, user-defined type, function, trigger,
or sequence, you can supply information about it for future reference. You
can add information by using the COMMENT ON statement.
Change a table definition
Changing the definition of a table allows you to add new columns, change an existing column definition (change its length, default value, and so on), drop existing columns, and add and remove constraints.
Create and use ALIAS names
When you refer to an existing table or view, or to a physical file that consists of multiple members, you can avoid using file overrides by creating an alias. You can use the SQL CREATE ALIAS statement to do this.
Create and use views
A view can be used to access data in one or more tables or views. You create a view by using a SELECT statement.
Add indexes
You can use indexes to sort and select data. In addition, indexes help the system retrieve data faster for better query performance.
Catalogs in database design
A catalog is automatically created when you create a schema. There is also a system-wide catalog that is always in the QSYS2 library.
Drop a database object
The DROP statement deletes an object. Depending on the action requested, any objects that are directly or indirectly dependent on that object might also be deleted or might prevent the drop from happening.