ALTER SYNONYM

Function

ALTER SYNONYM is used to modify the attribute of a synonym.

Precautions

  • Only the synonym owner can be changed.
  • Only the system administrator has the permission to modify the synonym owner information.
  • The new owner must have the CREATE permission on the schema where the synonym resides.

Syntax

1
2
ALTER SYNONYM synonym_name
    OWNER TO new_owner;

Parameter Description

  • synonym

    Name of a synonym to be modified (optionally with schema names)

    Value range: A string compliant with the identifier naming rules

  • new_owner

    New owner of a synonym object

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

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
-- Create synonym t1.
CREATE OR REPLACE SYNONYM t1 FOR ot.t1;

-- Create user u1.
CREATE USER u1 PASSWORD 'user@111';

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

-- Delete synonym t1.
DROP SYNONYM t1;

-- Delete user u1.
DROP USER u1;

Helpful Links

CREATE SYNONYM and DROP SYNONYM