Synonyms

A synonym is a database object that serves as an alternative name or alias for another database object such as a table, view, stored procedure, or function.

In Database Explorer, you can perform operations on synonyms by using the shortcut menu. Right-click a synonym in Database Explorer to access options for specific tasks, such as creating, modifying, or deleting synonyms, or generating scripts for them.

Create a synonym

1. In Database Explorer, right-click a synonym or Synonyms node and select New Synonym.

2. In a SQL document, enter the CREATE SYNONYM statement.

3. At the bottom of the SQL document, click Apply Changes.

Edit a synonym

1. In Database Explorer, right-click the synonym you want to edit and select Open Editor.

2. In a SQL document, edit the synonym.

3. At the bottom of the SQL document, click Apply Changes.

Alternatively, in the top menu, select File > Save, or press Ctrl+S.

Delete a synonym

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

2. Click Yes to confirm the deletion.

Note

You cannot undo the drop synonym operation, as this action permanently deletes the synonym. To avoid data loss, back up the database before deleting the synonym.

Duplicate a synonym

1. In Database Explorer, right-click a required synonym and select Duplicate Object.

2. In the Duplicate Object dialog, configure the object settings:

  • In Destination connection, select the target server.
  • In Destination database, select the target database.
  • In Destination schema, select the target schema.
  • In New object name, specify the object name.
  • Select Drop destination object to drop the destination object if it already exists.
  • Optional: Select Script Changes, then select To New SQL Window to open the generated script in a new SQL document, or To Clipboard to copy it to the clipboard.

3. Click OK.

Generate a script for a synonym

1. In Database Explorer, right-click a required synonym and select Generate Script As, then select the statement type.

2. Select one of the following output options:

  • To New SQL Window – Opens the script in a new SQL document.
  • To File – Generates the script to a .sql file.
  • To Clipboard – Copies the script to the clipboard.

For more information, see Generate the DDL and DML statements for database objects.

Add a synonym to the Query Builder diagram

To add to Query Builder: In Database Explorer, right-click a required synonym and select Send To > Query Builder.

Add a synonym to the Master-Detail Browser document

To add to Master-Detail Browser: In Database Explorer, right-click a required synonym and select Send To > Master-Detail Browser.

View synonym properties

To view synonym properties, in Database Explorer, right-click the synonym or Synonyms node and select Show Details.

Object Viewer opens, displaying detailed information about the synonym.

Refresh the synonym

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

Open the Properties window

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

Filter synonyms

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

2. In the Filter Settings (Synonyms) dialog, configure the filter parameters.

3. Click OK to apply the filter.

Note

When you open the Synonyms 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 synonym

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

Name Description
New Synonym Opens a CREATE SYNONYM template in a new SQL document to create a synonym.
Open Editor Opens the synonym in a new SQL document containing the CREATE SYNONYM statement to create the synonym or change its code.
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.
Duplicate Object Opens the Duplicate Object dialog to duplicate the synonym.
Generate Script As Generates a script of the selected synonym using the CREATE, DROP, and DROP and CREATE statements. The script can be saved to a new SQL document or to a file, or copied to the clipboard.
Send to > Query Builder Adds the synonym to the Query Builder diagram.
Send to > Master Detail Browser Adds the synonym to the Master Detail Browser document.
Show Details Opens Object Viewer that displays 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 Synonyms node

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

Name Description
New Synonym Opens a CREATE SYNONYM template in a new SQL document to create a synonym.
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 synonyms should appear in Database Explorer.
Show Details Opens Object Viewer that displays 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 synonyms. Then right-click the selection and select the required option.

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

Name Description
Open Editor Opens the Synonym designer for each selected synonym to recreate or modify them.
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 > Link/Unlink Static Data Opens the Source Control Link Static Data dialog that displays the tables whose data you want to link.
Generate Script As Generates a script of the selected objects using the CREATE, DROP, and DROP and CREATE statements. The script can be generated to a new SQL document or to a file, or copied to the clipboard.
Send to > Query Builder Adds the selected synonyms to the Query Builder diagram.
Send to > Master Detail Browser Adds the selected synonyms to the Master Detail Browser document.
Delete Drops the selected synonyms from the database.
Shortcut: Delete

Bulk operations for multiple synonyms