Managing Constraints   «Prev 

Creating a unique index with Schema Manager

  1. Select the Schema Manager from the Oracle Enterprise Manager program group. Start Schema Manager by selecting the program from the Oracle Enterprise Manager group.
  2. Login in as user SCOTT with password TIGER and then click the OK button.
  3. The Schema Manager gives you a graphical view of all the database objects. To see a listing of indexes, click the plus sign to the left of the Indexes heading in the list box on the left.
  4. The Indexes listing contains all the schemas that the user SCOTT has access to. Click the plus sign to the left of the SCOTT schema to show the Indexes in that schema.
  5. To see the details of the DEPT_PRIMARY_KEY index, click the index name in the left list box.
  6. To create a new index, right click the SCOTT schema name.
  7. Select the Create menu choice.
  8. The Create Index form will prompt you for an index name. Enter A_UNIQUE_INDEX in the Name box.
  9. By default, the Create Index form starts with the first table in the schema in alphabetical order. This is the A_TABLE that you created in an earlier module, and is the one you want to use.
  10. The index also will contain the one column in the table, COLUMN1. To specify this column as part of the index, click the box to the left of the column name in the column list box.
  11. Once you select a column, it is given an order in the index; in this case, 1.
  12. You have to indicate that this is a unique index by selecting the Unique check box near the bottom of the Create Index form.
  13. The final step in creating the index is to click the Create push button at the bottom of the page.
  14. When you return to the Schema Manager, you can see that the A_UNIQUE_INDEX entry is now in the list of indexes. This is the end of the simulation.

Figure 64-6 SchemaManager Usage

Toplink Links
Although you can use the SchemaManager API directly, Oracle recommends that you create a TableCreator class and use its API (which, in turn, uses the SchemaManager). The TableCreator class owns one or more TableDefinition classes (one for each database table) and the TableDefinition class owns one or more FieldDefinition classes (one for each field).
The TableDefinition class lets you specify a database table schema in a generic format. At run time, TopLink uses the session associated with your TopLink project to determine the specific database type, and uses the generic schema to create the appropriate tables and fields for that database.