Create a persistent row for the entire database

I am still new to SQL, so I have some problems. I am running a Postgres database in Acqua Data Studio, with some queries that follow the same model.
Some variables in these queries are the same, but may change in the future ...

Thinking of an optimized database, it would be faster to change the constant value than to enter 20+ queries and change the same aspect in all of them.

Example:

SELECT *
FROM Table AS Default_Configs      
    LEFT JOIN Table AS Test_Configs
        ON Default_Configs.Column1 = 'BLABLABLA'

The view "BLABLABLA" can be "XXX", how can I make the "BLABLABLA" constant for each view that is created after this template?

+2
source share
1

, " ":

CREATE OR REPLACE FUNCTION f_my_constant()
  RETURNS text AS
$$SELECT text 'XXX'$$ LANGUAGE sql IMMUTABLE;

'BLABLABLA' .

IMMUTABLE .

, , , . . , , .


( . 9.2 ) Customized Option " " , , .., :

current_setting('constant.blabla')

: text , , .

:

:

+6

Source: https://habr.com/ru/post/1533183/


All Articles