ALTER SYNONYM
Description
Modifies the attributes of the SYNONYM object.
Precautions
- Currently, only the owner of the SYNONYM object can be changed.
- Only a system administrator has the permission to modify the owner of the SYNONYM object. When separation of duties is enabled, system administrators do not have the permission to change the owner of the SYNONYM object by default.
- The new owner must have the CREATE permission on the schema where the SYNONYM object resides.
- PUBLIC synonyms cannot be modified.
Syntax
1 2 |
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. It must comply with the naming convention.
- new_owner
Specifies the new owner of the 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 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
-- Create a system administrator. gaussdb=# CREATE USER sysadmin WITH SYSADMIN PASSWORD '********'; -- Switch the system administrator. gaussdb=# \c - sysadmin -- Create synonym t1. gaussdb=# CREATE OR REPLACE SYNONYM t1 FOR ot.t1; -- Create user u1. gaussdb=# CREATE USER u1 PASSWORD '********'; -- Assign permissions to the new user. gaussdb=# GRANT ALL ON SCHEMA sysadmin TO u1; -- Change the owner of synonym t1 to u1. gaussdb=# ALTER SYNONYM t1 OWNER TO u1; -- Delete synonym t1. gaussdb=# DROP SYNONYM t1; -- Revoke permissions from user u1. gaussdb=# REVOKE ALL ON SCHEMA sysadmin FROM u1; -- Delete user u1. gaussdb=# DROP USER u1; -- Switch to the initial user init_user. Replace init_user with the actual initial username. gaussdb=# \c - init_user -- Delete user sysadmin. gaussdb=# DROP USER sysadmin; |
Helpful Links
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot