How to Create Synonym in Snowflake?

  • Post author:
  • Post last modified:April 20, 2023
  • Post category:Snowflake
  • Reading time:4 mins read

Synonyms in relational databases allows you to create easily names for long table, view names, or any other objects such as sequence, procedure, function, materialized view. Databases such as Netezza, Oracle support creating and managing synonyms. The synonyms provide an alternate way of referencing tables or views that present in the current or other databases. The Snowflake database does not support creating synonym yet. In this article, we will check an alternate method similar to create synonym in Snowflake.

How to Create Synonym in Snowflake?

The Snowflake cloud database does not support creating SYNONYM, or ALIAS as of now. But, even in official Oracle to Snowflake migration guide, there are no proper alternative methods for synonym statements.

However, depending on the need and requirement, you can mimic CREATE SYNONYM using Snowflake views. For examples, you can create alternative view for long tables or views.

Following is the typical syntax of create synonym in Netezza.

CREATE SYNONYM synonym_name FOR table_reference;

Alternate Method to Create Synonym or Alias in Snowflake

You can view as an alternate method for table and views. For other objects, it is not possible to create a different name.

Following create view statement will allow you to view with a different name on top of the base table.

CREATE VIEW SYN_EMP
AS
SELECT *
FROM  TEST_DB.USERS.EMPLOYEE;

You can create a view on top of another view so it is possible to create different name for a view and use alternate name in place of original base view name.

Following example creates a different view on top of base view.

CREATE VIEW SYN_DAILY_REPORTS
AS
SELECT *
FROM  VIEW_DB.REPORTS.DAILY_REPORTS;

The mentioned method has limited usage but you can use this method for tables and other long views.

Related Articles,

Hope this helps 🙂