Keys

A primary key uniquely identifies each row in a table. A unique key enforces uniqueness for the columns it is defined on, ensuring no duplicate values. A foreign key establishes a relationship between two tables by enforcing that the value in one table must match a value in the referenced table primary key or unique key.

Database Explorer allows you to perform operations on keys using the shortcut menu. Right-click a key in Database Explorer to access commands for specific tasks, such as creating foreign, primary, or unique keys, editing, deleting, or renaming keys.

Create a foreign key

1. In Database Explorer, right-click the Keys node and select New Foreign Key.

2. On the Constraints tab of Table Editor:

2.1. Right-click the grid and select Add Foreign Key.

2.2. Configure the foreign key properties.

3. Click Apply Changes.

Create a primary key

1. In Database Explorer, right-click the Keys node and select New Primary Key.

2. On the Constraints tab of Table Editor:

2.1. Right-click the grid and select Add Primary Key.

2.2. Configure the primary key properties.

3. Click Apply Changes.

Create a unique key

1. In Database Explorer, right-click the Keys node and select New Unique Key.

2. On the Constraints tab of Table Editor:

2.1. Right-click the grid and select Add Unique Key.

2.2. Configure the unique key properties.

3. Click Apply Changes.

Edit a key

1. In Database Explorer, right-click the key you want to edit (primary, foreign, or unique) and select Edit Primary Key.

2. On the Constraints tab of Table Editor, update the key properties.

3. Click Apply Changes.

Rename a key

1. In Database Explorer, right-click the key you want to rename and select Rename, or press F2.

2. Enter the new key name.

3. Click Yes to confirm the renaming of the key.

View the key properties

View the key properties in one of these ways:

  • Double-click the required key.
  • In Database Explorer, right-click the key and select Show Details.

Object Viewer opens, displaying detailed information about the key.

Delete a key

1. In Database Explorer, right-click the key you want to delete and select Delete, or press Delete.

2. Click Yes to confirm deleting the key, or No to discard the operation.

Refresh the key

To update the key to reflect the latest changes, in Database Explorer, right-click the key or Keys node and select Refresh, or press F5.

Open the Properties window

To open the Properties window, in Database Explorer, right-click the key and select Properties, or press F4.

Filter keys

1. In Database Explorer, right-click the Keys node and select Filter.

2. In the Filter Settings dialog, configure the filter parameters.

3. Click OK to apply the filter.

Note

When you open the Keys node, the number of objects it contains appears in parentheses next to the node name. This number changes based on your filter settings.

Shortcut menu options for a specific key

The following table describes the shortcut menu options, which appear when you right-click a specific key in Database Explorer.

Name Description
Edit Key Opens the Constraints tab of Table Editor to modify an existing key.
Note: The option name varies by key type, such as Edit Primary Key or Edit Foreign Key.
Enable Turns on the selected key.
Disable Turns off the selected key.
Show Details Opens Object Viewer to view object details.
Delete Drops the selected object from the database.
Shortcut: Delete
Refresh Updates the object to reflect the latest changes.
Shortcut: F5
Properties Opens the Properties pane to view the object information.
Shortcut: F4

Shortcut menu options for the Keys node

The following table describes the shortcut menu options, which appear when you right-click the Keys node in Database Explorer.

Name Description
New Foreign Key Opens the Constraints tab of Table Editor to add a foreign key.
New Primary Key Opens the Constraints tab of Table Editor to add a primary key.
New Unique Key Opens the Constraints tab of Table Editor to add a unique key.
Source Control > Source Control Manager Opens Source Control Manager, where you can track and manage changes to database schema and static data.
When Source Control Manager is already open, this option refreshes it.
Source Control > Commit Opens Source Control Manager with all local changes (if any) selected and ready to commit.
When Source Control Manager is already open, this option refreshes it and selects all local database changes.
Source Control > Get Latest Opens Source Control Manager with all remote changes (if any) selected, ready to pull using Get Latest.
When Source Control Manager is already open, this option refreshes it and selects all remote database changes.
Filter Opens the Filter Settings dialog to control which keys should appear in the table in Database Explorer.
Show Details Opens Object Viewer to view object details.
Refresh Updates the object to reflect the latest changes.
Shortcut: F5

Note

The Source Control shortcut menu is available only after you link the corresponding database to a source-control system.

Bulk operations

In Database Explorer, hold down Ctrl and select multiple keys. Then right-click the selection and select the required option.

The following table describes the shortcut menu options available for multiple keys.

Name Description
Source Control > Source Control Manager Opens Source Control Manager, where you can track and manage changes to database schema and static data.
When Source Control Manager is already open, this option refreshes it.
Source Control > Commit Opens Source Control Manager with all local changes (if any) selected and ready to commit.
When Source Control Manager is already open, this option refreshes it and selects all local database changes.
Source Control > Get Latest Opens Source Control Manager with all remote changes (if any) selected, ready to pull using Get Latest.
When Source Control Manager is already open, this option refreshes it and selects all remote database changes.
Source Control > View Changes History Opens the Changes History document that displays all revisions, including committed changes.
Source Control > Link/Unlink Static Data Opes the Source Control Link Static Data dialog that displays the tables whose data you want to link.
Delete Drops the selected keys from the database.
Shortcut: Delete