Updating Database Expiry Date in PostgreSQL

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.

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.

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.

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.

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.

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.

Checking PostgreSQL Database Size