4

PostgreSQL v12.6 DBEaver 7.1.0

How to set SQL script parameters in DBeaver or PgAdmin? (any working option is welcome)

This script works perfectly when I run it as a script on DB initialization
(i.e. from Docker's postgres:12.6-alpine in /docker-entrypoint-initdb.d/init.sql. No doubts this script is valid for execution through psql.

\set app_schema  my_schema
\set app_username  my_app
\set app_password  my_app_pwd
 
CREATE SCHEMA :app_schema;
ALTER SCHEMA :app_schema OWNER TO "admin";
CREATE USER :app_username WITH PASSWORD :'app_password';

But I cannot find a way to set parameters in DBeaver script. Non of these is valid:

\set app_schema  my_schema
set app_schema=my_schema
set :app_schema=my_schema
:app_schema=my_schema
... and many more ...

As well did not find any information about doing this in PGAdmin.

diziaq
  • 6,881
  • 16
  • 54
  • 96

1 Answers1

0

Just had this issue. In DBeaver, the default control command prefix is @. Under File > Properties > Editors > SQL Processing > Control command prefix you can set that to \ and it should work.

enter image description here

Just noting however, that there might be a good reason to why Dbeaver set @ as the default command prefix and there may be unknown implications to changing it to \.

Aidan Do
  • 86
  • 1
  • 7