Skip to content
Developer Edition runs on one host and does not require a product license file. Need multi-host deployment or performance testing at scale? Explore Enterprise Edition

ALTER USER command

The ALTER USER command is used to set the home schema and home graph for the current user in the catalog, or modify a user's password.

The current active session remains valid after the home schema or home graph is set, or the password is changed.

Prerequisites

  • Only the user with the role ADMIN can set the home schema or home graph for all users. Other users can only set their own home schema or home graph.
  • Each user can only change their own passwords.

Syntax

alter_user_schema
ALTER USER user_name SET HOME_SCHEMA schema_reference
alter_user_graph
ALTER USER user_name SET HOME_GRAPH schema_reference / graph_name
alter_user_password_command
ALTER USER user_name WITH PASSWORD " new_password "

alter_user_schema ::=
    'ALTER' 'USER' user_name 'SET' 'HOME_SCHEMA' schema_reference
alter_user_graph ::=
    'ALTER' 'USER' user_name 'SET' 'HOME_GRAPH' (schema_reference '/')? graph_name
alter_user_password_command ::=
    'ALTER' 'USER' user_name 'WITH' 'PASSWORD' '"' new_password '"' 

Parameters

user_name

The name of the user whose home schema, home graph, or password is to be set or changed.

schema_reference

The reference to the path of the schema.

  • When setting the home schema for a user, it specifies the path of the schema to be set as the home schema. If not specified, the home schema for the user defaults to /default_schema.
  • When setting the home graph for a user, 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, 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 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. The name is case-sensitive and must match the name of an existing graph. You can use CREATE GRAPH to create a graph.

new_password

The new password for the user.

The new password must be enclosed in either double quotes or single quotes, be at least 8 characters in length, and include at least one digit, one lowercase letter, and one uppercase letter.

Examples

Set the home schema

'''
// Create a schema
CREATE SCHEMA IF NOT EXISTS /my_schema
'''

'''
// Set the home schema for the current user
ALTER USER root SET HOME_SCHEMA /my_schema
'''

Set the graph in the current schema as the home graph

'''
// Create a graph type
CREATE GRAPH TYPE IF NOT EXISTS home_graph_type AS {}
'''

'''
// Create a graph
CREATE GRAPH IF NOT EXISTS homegraph TYPED home_graph_type
'''

'''
// Set the home graph for the current user
ALTER USER root SET HOME_GRAPH homegraph
'''

Set the graph in the specified schema as the home graph

'''
// Create a graph type
CREATE GRAPH TYPE IF NOT EXISTS home_graph_type AS {}
'''

'''
// Create a graph
CREATE GRAPH IF NOT EXISTS homegraph TYPED home_graph_type
'''

'''
// Create a schema
CREATE SCHEMA IF NOT EXISTS /my_schema
'''

'''
// Set the schema for the current session
SESSION SET SCHEMA /my_schema
''' 

'''
// Set the home graph for the current user
ALTER USER root SET HOME_GRAPH /default_schema/homegraph
'''

Modify a user's password

ALTER USER root WITH PASSWORD "Password123"

More information

  • To view the information about the current user, use SHOW CURRENT_USER.
  • To view the information about all users who are invited to the current service group, use SHOW USERS.
  • To view the information about the current session, use SHOW CURRENT_SESSION.
  • To view the information about all sessions, use SHOW SESSIONS.