16.10.2015 Views

Getting Started with IBM Data Studio for DB2

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Chapter 2 – Managing your database environment 83<br />

Field<br />

Primary Key<br />

<strong>Data</strong> Type<br />

Length<br />

Scale<br />

Not Null<br />

Generated<br />

Default<br />

Value/Generate<br />

d Expression<br />

Description<br />

Click this box if you want this column to be the primary key <strong>for</strong> the<br />

table.<br />

<strong>Data</strong> type of the column. Click in the field to activate it <strong>for</strong> editing and<br />

then open the pull down menu to see all the data types supported in<br />

the drop down menu.<br />

The length of the column. For some of the data types it is fixed and in<br />

those cases you cannot edit this.<br />

Specify the scale <strong>for</strong> the column type wherever applicable. Again, if it’s<br />

not applicable to this data type, you won’t be able to edit this.<br />

Click the box if the column value cannot be null. This option is<br />

automatically selected <strong>for</strong> primary key columns, because primary keys<br />

are not allowed to be null.<br />

Click this box if you want the <strong>DB2</strong> system to automatically generate<br />

the value of this column based on a default value or expression that<br />

you provide.<br />

If the Generated box is selected, you need to specify a default value or<br />

an expression that the <strong>DB2</strong> system will evaluate to generate the value<br />

of this column whenever a value is not specified in theINSERT<br />

statement. For example a total salary column can be the sum of basic<br />

salary (column namebasicSalary) and allowances (column name<br />

allowances). You can specify <strong>for</strong>salaryColumn as Generated<br />

expression ofbasicSalary + allowances<br />

Table 2.2 – Column details<br />

In the planned changes bar of the object list editor, you will see the count of changed<br />

objects update to include the new table. In Section 2.4.5, you will deploy the new table to<br />

the database <strong>with</strong> other objects in a change plan.<br />

2.4.3 Creating indexes<br />

To create an index on a column of the table:<br />

<br />

Right-click the Indexes folder in the Administration Explorer and select Create Index.<br />

You must specify what table will use this index. Expand theMYSCHEMA node and select<br />

theMYTABLE table, as shown in Figure 2.17, and click OK. The Properties view <strong>for</strong> the<br />

new index opens.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!