Updated on 2025-02-27 GMT+08:00

ALTER SYNONYM

Description

Alters the attributes of the SYNONYM object.

Precautions

  • Currently, only the owner of the SYNONYM object can be changed.
  • Only system administrators have the permission to modify the owner of the SYNONYM object.
  • The new owner must have the CREATE permission on the schema where the SYNONYM object resides.

Syntax

ALTER SYNONYM synonym_name
    OWNER TO new_owner;

Parameters

  • synonym_name

    Specifies the name of the synonym to be modified, which can contain the schema name.

    Value range: a string that complies with the Identifier Naming Conventions.

  • new_owner

    Specifies the new owner of the SYNONYM object.

    Value range: a string. It must be a valid username.

Examples

-- Create synonym t1.
openGauss=# CREATE OR REPLACE SYNONYM t1 FOR ot.t1;

-- Create user u1.
openGauss=# CREATE USER u1 PASSWORD '********';

-- Change the owner of synonym t1 to u1.
openGauss=# ALTER SYNONYM t1 OWNER TO u1;

-- Drop synonym t1.
openGauss=# DROP SYNONYM t1;

-- Drop user u1.
openGauss=# DROP USER u1;

Helpful Links

CREATE SYNONYM and DROP SYNONYM