Answer the question
In order to leave comments, you need to log in
How to specify schema when connecting to Postgresql nodejs?
Good afternoon!
There is an application on nodejs (express).
My question is: how can I specify the schema that I need to use when connecting to the database through pg (the default is public, I need another one)?
Or how do I even need to refer to a specific schema?
Answer the question
In order to leave comments, you need to log in
SET search_path TO <название нужной схемы>,public;
But this is a rather dumb decision if there are a lot of circuits.
And even more dumb, if there are tables with the same names in different schemas.
In my practice, I always specify the scheme in requests:
SELECT * FROM "myschema"."mytable";
UPDATE "catalog"."goods" SET "price" = 100 WHERE "id" = 10;
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question