set “VALID UNTIL” value with a calculated timestamp
问题 I want to create user or change password with a timestamp calculated over current time. example: # CREATE USER user WITH PASSWORD 'password12345678' VALID UNTIL '(NOW() + interval 1 month)'; of course it's not valid: ERROR: invalid input syntax for type timestamp with time zone: "(NOW() + interval 1 month)" 回答1: Utility commands like CREATE USER do not accept expressions, only literals. You need dynamic SQL. DO $do$ BEGIN EXECUTE format($$CREATE USER myuser WITH PASSWORD 'password12345678'