0

Can postgresql (specifically 9.6) stored procedures read/modify a separate database, or can they only operate on data within the local database where they are defined?

Rusty Lemur
  • 1,697
  • 1
  • 21
  • 54

1 Answers1

2

Postgres 9.6 does not have stored procedures, which were introduced with Postgres 11.

You probably mean Postgres functions, which have been there since time immemorial. It's a widespread misconception to call those "stored procedures".

Both are confined to the database in which they are executed - as Postgres will tell you if you try to prefix a database name to an object name:

ERROR:  cross-database references are not implemented:

Unless you use the Foreign Data Wrapper infrastructure (you probably want the additional module postgres_fdw with that) or dblink, which allow exactly that after all ...

Erwin Brandstetter
  • 605,456
  • 145
  • 1,078
  • 1,228