0

(I suspect the answer is yes, but I don't see it confirmed anywhere.)

In psql we can set environment variables using the \setenv {name} {value} command.

Are these the same environment variables as the ones in the shell?


For reference the relevant page in the documentation.

1 Answer 1

2

Yes. \setenv just calls the C library function setenv(). This changes the environment settings of the psql process and has no effect outside of that.

2
  • So what happens to an environment variable when we exit a psql session in which it was changed?
    – Niels Bom
    Commented Oct 14, 2022 at 13:57
  • 2
    It disappears along with the process.
    – user234725
    Commented Oct 15, 2022 at 5:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.