INVITE USER command¶
The INVITE USER command invites a user to a service group.
When inviting a user, you can optionally set the home schema and home graph for the user. The home schema and home graph are used as the default schema and graph of the session when the user connects to the service group.
After the user is invited, you need to grant the action CONNECT on the service group to enable the user to connect to the service group. To enable the user to access resources in the service group, you need to grant the necessary roles or privileges to the user. For more information, see Authorization.
Prerequisites¶
- To invite a user, you must be the user with the role
ADMINin the service group. - The user to be invited is already created. For more information, see Create users.
Syntax¶
- invite_user_command
invite_user_command ::=
'INVITE' 'USER' user_name ('SCHEMA' schema_reference)? ('GRAPH' (schema_reference '/')? graph_name)?
Parameters¶
user_name¶
The name of the user to be invited.
schema_reference¶
The reference to the path of the schema.
- When setting the home schema for the user to be invited, it specifies the path of the schema to be set as the home schema. If not specified, the home schema for the user to be invited defaults to
/default_schema. - When setting the home graph for the user to be invited, it specifies the schema path of the graph to be set as the home graph. To set a graph that resides outside the schema in the current session as the home graph for the user to be invited, the schema path must be specified. If not specified, the home graph to be set for the user must be in the current schema.
The path is case-sensitive and must match the path of an existing schema. Both absolute and relative schema paths can be used in the command. You can use CREATE SCHEMA to create a schema. For information about setting and viewing the schema for the current session, see SESSION SET and SHOW CURRENT_SCHEMA.
Note
Setting a home schema or home graph while inviting a user does not grant the user USAGE on the parent schema. If the home schema is not /default_schema, grant the required USAGE separately. For more information, see Schema access control.
graph_name¶
The name of the graph to be set as the home graph for the user.
The name is case-sensitive and must match the name of an existing graph in the schema specified by schema_reference. You can use CREATE GRAPH to create a graph.
If not specified, no graph is set as the home graph for the user.
Examples¶
Invite a user and set the current schema as the user's home schema¶
INVITE USER user1 SCHEMA /default_schema
The preceding example invites a user named user1 and sets the current schema /default_schema as the home schema for user1.
Invite a user and set the graph in the current schema as the user's home graph¶
'''
// Create a schema
CREATE SCHEMA IF NOT EXISTS /my_schema
'''
'''
// Set schema in the current session to the created schema
SESSION SET SCHEMA /my_schema
'''
'''
// Create a graph type in the created schema
CREATE GRAPH TYPE IF NOT EXISTS home_graph_type AS {}
'''
'''
// Create a graph in the created schema
CREATE GRAPH IF NOT EXISTS test_graph TYPED home_graph_type
'''
'''
// Invite a user and set the home graph for the user
INVITE USER user1 GRAPH test_graph
'''
The preceding example demonstrates how to invite a user named user1 and set the graph test_graph in the current schema /my_schema as the home graph for user1.
Invite a user and set the graph in the specified schema as the user's home graph¶
'''
// Create a graph type in the default schema
CREATE GRAPH TYPE IF NOT EXISTS home_graph_type AS {}
'''
'''
// Create a graph in the default schema
CREATE GRAPH IF NOT EXISTS test_graph TYPED home_graph_type
'''
'''
// Create a schema
CREATE SCHEMA IF NOT EXISTS /my_schema
'''
'''
// Set schema in the current session to the created schema
SESSION SET SCHEMA /my_schema
'''
'''
// Invite a user and set the home graph for the user
INVITE USER user1 GRAPH /default_schema/test_graph
'''
The preceding example demonstrates how to invite a user named user1 and set the graph test_graph in the schema /default_schema as the home graph for user1 when the schema in the current session is set to /my_schema.