DB2 Data definition language statements

DB2 Statements in Cobol Program DB2 Create Statement

Advertisements


Data Definition Language is used to define (CREATE), alters (ALTER) and deletes (DROP) the database objects.

Normally these DDL statements will be handled by DBA.

The database objects include schemas, tables, views, sequences, catalogs, indexes, and aliases.

The main DDL statements are:

	a. CREATE
	b. ALTER
	c. DROP

CREATE:

CREATE statement is used to create the DB2 objects.

The database objects include schemas, tables, views, sequences, catalogs, indexes, and aliases

CREATE concept explained in detail here .

ALTER:

ALTER can be used to add/delete/modify the DB2 Objects which already defined during the CREATE.

Primary and foreign key also can be defined by using ALTER once the table got created.

For performing ALTER, user required SYSADM or SYSCTRL authority and DBADM authority on DATABASE.

ALTER concept explained in detail here .

DROP:

DROP statement used to DROP the DB2 objects created.

DROP will also drop the data in it along with Object dropping.

To DROP the objects SYSADM or SYSCTRL authority along with DBADM authority on DATABASE.

DROP concept explained in detail here .

DDL- Columns Definition:

Columns can be defined based on required value to be stored in the column by using the data types in DB2.

Column name is used to identify the data in the column.

Column name mostly describes about the characteristics of attribute/column.

Column name maximum length is 30 characters.

DATA TYPEs:

Data type used to specify the type of the data going to store in the particular attribute or column.

Every column in the table must have a data type.

The data type also can specify the range of column/attribute.

The data type needs to specify during the creation of table.

All the values inserting into the column or attribute should follow the data type.

The data types of a column can also change.

The new data type can applied to the data associated in the column during the reorganization.

COBOL Equivalent to DB2 data types:

Data Types concept explained in detail here .


DB2 Statements in Cobol Program DB2 Create Statement

Advertisements