DROP SYNONYM

2024-04-19 08:42:50  Updated

Purpose

You can use this statement to drop a synonym.

Syntax

DROP [PUBLIC] SYNONYM [ schema. ]synonym_name [FORCE];

Parameters

Parameter Description
PUBLIC You can specify PUBLIC to drop a public synonym. If you do not specify PUBLIC, a private synonym is dropped.
schema The schema where the synonym is located. If schema. is omitted, the synonym in your own schema is dropped. If PUBLIC is specified, schema cannot be specified for the synonym.
synonym_name The name of the synonym.
FORCE By specifying FORCE, you can drop a synonym even if it has dependent tables or user-defined types.

Examples

  • Drop a private synonym.

    obclient> DROP SYNONYM user1.syn1;
    Query OK, 0 rows affected
    
  • Drop a public synonym.

    obclient> DROP PUBLIC SYNONYM syn2;
    Query OK, 0 rows affected
    

Considerations

The following describes the requirements for dropping different types of synonyms:

  • To drop a private synonym:

    • Make sure that the synonym to be dropped is in the corresponding schema.

    • Make sure that you have the DROP ANY SYNONYM privilege.

  • To drop a public synonym:

    • You must specify the PUBLIC keyword and must not specify schema.

    • You must have the DROP PUBLIC SYNONYM privilege.

Contact Us