DB2 Synonyms Vs Alias -7 Top Differences

DB2 Synonyms

  1. Synonyms can be thought of as alternative names for tables and views. No authorization is required to define a synonym.
  2. A synonym designates a synonym when it is preceded by the keyword SYNONYM, as in CREATE SYNONYM and DROP SYNONYM. In all other contexts, a synonym designates a local table or view and can be used wherever the name of a table or view can be used in an SQL statement.
  3. Authorization or the CREATE ALIAS privilege is required to define an alias. No authorization is required to define a synonym.
  4. A synonym can only be defined on the name of a table or view at the current server.
  5. A synonym can only be defined on the name of an existing table or view.
  6. But dropping a table or view does drop its synonyms.A synonym can only be used at the DB2 subsystem where it is defined.
  7. For creating Synonym must mention Schema

DB2 Alias

  1. Aliases can be thought of as alternative names for tables and views
  2. An alias can be defined at a local server and can refer to a table or view that is at the current server or a remote server. The alias name can be used wherever the table name or view name can be used to refer to the table or view in an SQL statement. The rules for forming an alias name are the same as the rules for forming a table name or a view name, as explained below. A fully qualified alias name (a three-part name) can refer to an alias at a remote server. However, the table or view identified by the alias at the remote server must exist at the remote server.
  3. Authorization or the CREATE ALIAS privilege is required to define an alias.
  4. An alias can be defined on an undefined name.
  5. Dropping a table or view has no effect on its aliases.
  6. For creating Alias Schema is not required
  7. An alias defined at one DB2 subsystem can be used at another DB2 subsystem.

Author: Srini

Experienced software developer. Skills in Development, Coding, Testing and Debugging. Good Data analytic skills (Data Warehousing and BI). Also skills in Mainframe.