Setting the Validity Period of an Account
Precautions
When creating a user, you need to specify the validity period of the user, including the start time and end time.
To enable a user not within the validity period to use its account, set a new validity period.
Procedure
- Log in as the OS user omm to the primary node of the database. 
- Run the following command to connect to the database: - gsql -d postgres -p 8000- postgres is the name of the database to be connected, and 8000 is the port number of the database primary node. - If information similar to the following is displayed, the connection succeeds: - gsql ((openGauss x.x.x build 50dc16a6) compiled at 2020-11-29 05:49:21 commit 1071 last mr 1373) Non-SSL connection (SSL connection is recommended when requiring high-security) Type "help" for help. postgres=#
- Run the following command to create a user and specify the start time and end time: - postgres=# CREATE USER joe WITH PASSWORD 'xxxxxxxxx' VALID BEGIN '2015-10-10 08:00:00' VALID UNTIL '2016-10-10 08:00:00';- The user is created if the following information is displayed: - CREATE ROLE
- If the user is not within the specified validity period, run the following command to set the start time and end time of a new validity period. - postgres=# ALTER USER joe WITH VALID BEGIN '2016-11-10 08:00:00' VALID UNTIL '2017-11-10 08:00:00';- The start time and end time of the new validity period is set successfully if the following information is displayed: - ALTER ROLE
NOTE:
- If VALID BEGIN and VALID UNTIL are not specified in the CREATE ROLE syntax, the start time and end time of a user's operation are not limited.
- If VALID BEGIN and VALID UNTIL are not specified in the ALTER ROLE syntax, the start time and end time of a user's operation are not modified and the original settings are used.