Help Center/ GaussDB/ Developer Guide(Centralized_V2.0-8.x)/ FAQ/ How Do I Set the Validity Period of an Account?
Updated on 2025-05-29 GMT+08:00

How Do I Set the Validity Period of an Account?

Answer: During the use of the database, some users are created to perform related operations on the database. When creating a user, you need to restrict the operation period (that is, the start time and end time of the validity period) of the user. The setting method is as follows:

  1. Use gsql to connect to the database.
  2. Run the following command to create a user and specify the start time and end time:

    gaussdb=# CREATE USER jack WITH PASSWORD '********' VALID BEGIN '2015-10-10 08:00:00' VALID UNTIL '2016-10-10 08:00:00'; 
    CREATE ROLE

    The user is created if the CREATE ROLE information is displayed:

  3. If the user is not within the specified validity period, run the following command to set a new validity period, including the start time and end time.

    gaussdb=# ALTER USER jack WITH VALID BEGIN '2016-11-10 08:00:00' VALID UNTIL '2017-11-10 08:00:00'; 
    ALTER ROLE

    The start time and end time of the new validity period is set successfully if the ALTER ROLE information is displayed: