You can now clone the schema as a non-super user. This two functions are created while creating the extension:
GRANT_CLONE_SCHEMA_PRIVILEGES - Grants the privileges to a non-super user to clone the schema.
REVOKE_CLONE_SCHEMA_PRIVILEGES - Revokes the privileges from a non-super user for cloning the schema.
GRANT_CLONE_SCHEMA_PRIVILEGES
You can grant the clone schema privileges to a non-super user using this function.
Syntax:
Where,
user_name
Name of the user to whom privileges are to be granted to do local cloning.
allow_remote_schema_clone
Optionally provide a boolean value to this parameter to control the remote cloning by the user. By default the value is set to False. The true value grants user the privileges to do remote cloning.
print_commands
Optionally provide a boolean value to this parameter to control printing of the executed commands. By default the value is set to false. The true value prints the executed commands on the terminal.
This example shows how to grant a non-super user ec2-user the privileges for local and remote cloning:
REVOKE_CLONE_SCHEMA_PRIVILEGES
You can revoke the clone schema privileges from a non-super user using this function.
Syntax:
Where,
user_name
Name of the user from whom we want to revoke the cloning privileges.
revoke_remote_schema_clone
Optionally provide a boolean value to this parameter to control the remote cloning by the user. By default the value is set to False. The true value revokes the remote cloning privileges from the user.
print_commands
Optionally provide a boolean value to this parameter to control printing of the executed commands. By default the value is set to false. The true value prints the executed commands on the terminal.
This example shows how to revoke cloning privileges from the ec2-user user.
Examples
This example shows how to clone a schema locally as a non-super user:
Create a non-super user named forcs for this example:
Give CREATE privileges to forcs user on edb database:
Create the following extensions:
Create the log directory for cloning:
Give clone schema privilege to forcs user:
Connect to edb database as forcs user:
Create a foreign server and a user mapping:
Create a sample schema and tables:
Clone the schema locally:
This example shows how to clone a schema remotely as a non-super user:
Create a non-super user named forcs for this example:
Give CREATE privileges on edb database to forcs user:
Create the following extensions:
Create the log directory for cloning:
Give the clone schema privileges to the non-super user forcs:
Connect to the edb database as forcs user:
Create a foreign server and user mapping in source and target database:
Clone the schema from source to target database using remotecopyschema function: