Updated on 2025-05-29 GMT+08:00

DROP SYNONYM

Description

Deletes a synonym.

Precautions

Only the synonym owner or a user with the DROP ANY SYNONYM permission can run the DROP SYNONYM command. System administrators have this permission by default.

Syntax

DROP [PUBLIC] SYNONYM [ IF EXISTS ] synonym_name [ CASCADE | RESTRICT ];

Parameters

  • PUBLIC

    (Optional) Deletes PUBLIC synonyms.

  • IF EXISTS

    Reports a notice instead of an error if the specified synonym does not exist.

  • synonym_name

    Specifies the name (optionally schema-qualified) of the synonym to be deleted.

  • CASCADE | RESTRICT
    • CASCADE: automatically deletes the objects (such as views) that depend on the synonym.
    • RESTRICT: refuses to delete the synonym if any objects depend on it. This is the default action.

Examples

1
2
3
4
-- Create a synonym.
gaussdb=# CREATE OR REPLACE SYNONYM test_tbl1 FOR test_tbl1;
-- Delete the synonym.
gaussdb=# DROP SYNONYM test_tbl1;

Helpful Links

ALTER SYNONYM and CREATE SYNONYM