Altering database objects

You can use the Properties view to alter the properties of a database object and then generate and run a DDL script to apply the changes to the database.

Before you begin

You must have the appropriate authority to alter objects in the database. A connection to the database must also exist.

About this task

The steps in this task assume that you are changing a database that is not a DB2® for Linux, UNIX, and Windows database. You can change only one object at a time.

There is limited support for preserving data when you alter an object. When you alter a table, IBM® Data Studio determines whether the modifications can be performed with an ALTER TABLE statement. If an ALTER TABLE statement cannot support the requested modifications, the generated DDL includes commands to create a backup of the original table before creating the modified table. When a backup is required, a statement to copy the backed-up data to the modified table is also created. This statement is intended as a template for you to modify as needed to support the unique requirements of the existing data and table modifications.

Procedure

  1. Find the object that you want to alter in the Object List or in the Data Source Explorer.
    Restriction: You can use the Object List only for DB2 for z/OS® databases that are version 8 or later.
  2. Optional: To determine if changing this object impacts other objects, right-click the object and then click Analyze Impact.
  3. Right-click the object and then click Alter.
    Tip: Alternatively, you can select the object and then click the Edit icon image (Edit) icon in the Properties view.

    The object is displayed in the Properties view. For databases that support the Object List, the object is also displayed in the Object List with an icon next to it to indicate that it is being altered.

  4. Use the properties tabs in the Properties view to change the various attributes of the object.

    For more information about the attributes for an object, see Data object properties.

  5. When you are finished changing the attributes, click the Image of Review and deploy changes icon (Review and deploy changes) icon. The Review and Deploy dialog opens.
  6. Review the generated DDL.

    When you are modifying a table and the generated DDL includes commands to back up the existing table, you might need to modify the DDL to copy the data from the backup to the altered table. Use the generated DDL as a template.

    You cannot type directly in the DDL section of the dialog. If you want to modify the generated DDL script, click Edit. The script opens in the SQL and XQuery editor, where you can modify and run the DLL. You can also use the editor to start the Job Manager, where you can schedule a time to run the script.

  7. If you are satisfied with the generated DDL and want to run the DDL immediately, click Run and then click Finish.

Results

The generated DDL is run on the database, and the database object is changed according to the changes that you made in the Properties view. The SQL Results view displays the results, including any errors that occurred.

What to do next

Alter any objects that are impacted by the changes that you made to this object.

Feedback