Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting my postgresql db version?

Tags:

On SQlite I could do a query for PRAGMA user_version; and I could set the version if need be too. Is there anything in postgres that could do the same thing?

I tried select version() but that gets the literal version of postgres, and not a custom set version.

As an update: I researched commenting on databases. Perhaps this could be solution... commenting docs

like image 880
Andrew Graham-Yooll Avatar asked May 16 '17 15:05

Andrew Graham-Yooll


People also ask

How do I know if PostgreSQL is installed?

3) Verify the Installation The quick way to verify the installation is through the psql program. First, click the psql application to launch it. The psql command-line program will display. Second, enter all the necessary information such as the server, database, port, username, and password.

How do I check my PostgreSQL version DBeaver?

Option 1: SELECT version() This option is handy for when you're connected to a PostgreSQL database using a GUI such as PgAdmin, DBeaver, Azure Data Studio, etc. But you can run the same query when you're connected to a PostgreSQL database using the psql command line interface (CLI).


1 Answers

You can set a custom configuration parameter. The parameter name must contain a dot, e.g.:

set my.version to 4;
select current_setting('my.version') as version;

 version 
---------
 4
(1 row)

A parameter defined in this way is local to the current session. If you want to define a default value for the parameter for all sessions you can add it to the configuration file postgresql.conf (for all databases in the server). Alternatively, it is possible to set the default value for a database in the command:

set my.version to 4;
alter database my_database set my.version from current;

See also:

  • Setting Parameters
  • Customized Options
  • ALTER DATABASE
like image 136
klin Avatar answered Sep 23 '22 10:09

klin