by Hafiz Junaid
Updating the database expiry date in PostgreSQL is a common task that can be accomplished through a few simple steps using the command prompt. Here’s the easiest method to update the expiry date:
Steps to Update Database Expiry Date in PostgreSQL
1. Connect to PostgreSQL
First, you need to open your terminal or command prompt. You can do this manually or using a shortcut key (Ctrl + Alt + T).
To connect to PostgreSQL using the terminal, run the following command (this example is for Linux):
sudo su postgres //example of linux
After running this command, you will be prompted to enter your PostgreSQL password. Enter the password and press Enter. You should now be logged in as the PostgreSQL superuser.
![](/web/image/8653-6d918170/image1.jpg?access_token=6c608ab0-e60f-48d4-89f5-6710eed7bf4d)
Next, connect to the psql shell by running:
psql //example of linux
Once you execute this command, you will successfully connect to PostgreSQL, and you should see the psql prompt.
![](/web/image/8654-0bb0dd73/image2.jpg?access_token=bac285f5-b359-4f3e-aa45-659ee418ef91)
2. Run the Query
Now, connect to the specific database whose expiry date you want to update. For example, if your database name is Bazeee, run:
\c Bazeee
This command switches you to the Bazeee database.
![](/web/image/8652-729abdcf/image3.jpg?access_token=af837fbb-7bb5-496e-8c60-c660940e1936)
To check the configuration parameter table for the expiration date, execute the following query:
select * From ir_config_parameter;
This will list all the configuration parameters. Look for the entry with the key database.expiration_date.
![](/web/image/8657-260a0d10/image4.jpg?access_token=7b802551-66c8-41ed-b833-a61de05f22c8)
![](/web/image/8655-c92a7e05/image5.jpg?access_token=cafe02b0-d909-4dc8-a3c0-d2b1f2180dff)
Once you find the appropriate entry, note the id associated with the database.expiration_date. For instance, if the id is 26, you can update the expiration date with the following command:
update ir_config_parameter set value='2025-02-22 05:29:11' where id=26;
The result should show the updated expiration date for the database.
3. View the Results
To verify the change, you can rerun the SELECT query:
select * From ir_config_parameter WHERE id=26;
The result should show the updated expiration date for the database.
![](/web/image/8656-e2a411ca/image6.jpg?access_token=b7be3d48-3374-4443-a452-598af00e8e09)
Updating the database expiry date in PostgreSQL is straightforward once you connect to the PostgreSQL shell and identify the relevant configuration parameter. This method ensures you can easily manage database expiration settings without extensive command-line knowledge.
By following these steps, you can effectively update the expiry date of your PostgreSQL database and ensure it remains accessible as needed.
Need more development tips?
Stay tuned to our blog.