HiveBrain v1.2.0
Get Started
← Back to all entries
snippetsqlModerate

How do I set and get custom database variables?

Submitted by: @import:stackexchange-dba··
0
Viewed 0 times
databasecustomgetvariableshowandset

Problem

Using PGAdmin III I can right-click on a database, navigate to the Variables tab, and put a variable name-value property on the database itself. Is there a way to customize these? I saw an application_name variable, but I'd like to have an application_version variable.

Solution

To add to @dezso's answer, these variables can be changed with

SELECT set_config('class.name', 'value', valid_for_transaction_only::boolean)


and read with

SELECT current_setting('class.name')


See this link for more info: http://www.postgresql.org/docs/9.3/static/functions-admin.html

Code Snippets

SELECT set_config('class.name', 'value', valid_for_transaction_only::boolean)
SELECT current_setting('class.name')

Context

StackExchange Database Administrators Q#29961, answer score: 11

Revisions (0)

No revisions yet.