I am trying to do this in a SQL script that I pass to psql:
ALTER DATABASE dbname SET SEARCH_PATH TO myschema,public
but I need to dbnamedynamically set the current database, not hard-coded.
Is this possible in PostgreSQL? I tried this, but it does not work:
ALTER DATABASE (select current_database()) SET SEARCH_PATH TO myschema,public;
source
share