snippetsqlModerate
How do I set and get custom database variables?
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
and read with
See this link for more info: http://www.postgresql.org/docs/9.3/static/functions-admin.html
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.