Every time I run postgres instance, I need to manually set the search_path to be to ag_catalog by SET search_path=ag_catalog;
and then load the age, is there a way makes me don’t need to every time to do that?
Question posted in PostgreSQL
The official documentation can be found here.
The official documentation can be found here.
6
Answers
The default schema/search_path is ‘public’. In order to change the default search_path to ‘ag_catalog’ instead of public, you need to make a change to the
postgresql.conf
file inside your db cluster folder. You need to uncomment and change the search_path asYou have to change it every time unless you change the default configuration in your
postgresql.conf
file.To edit
postgresql.conf
:postgresql.conf
file.search_path
attribute then uncomment it and addag_catalog
.If you are using
age
in only one database in the cluster you can set thesearch_path
for just that database and not change the global setting.From here Alter Database
This means you can do:
If you need to undo that then:
to get back to the
postgresql.conf
setting.When you create a cluster, a folder with the same name as the cluster is created in the PostgreSQL directory. Within this folder, there is a file named
postgresql.conf
. Open this file using a text editor and locate the line that contains the term "search_path." Remove the ‘#’ symbol at the beginning of the line to uncomment it. Then, modify the line to set the value ofsearch_path
as follows:Adding to the existing answers, to set the search_path directly from the terminal, use vim to edit the
postgresql.conf
file. From the installed postgres directory:Once the editor opens up, type
/search_path
to jump to the line that needs to be modified. Pressi
to switch to ‘INSERT’ mode, which allows you to insert or delete characters. Once the change has been made, hitesc
to get out of ‘INSERT’ mode, then press:wq
to write and exit the editor.Open postgresql.conf file of the database using any text editor. Make respective changes in the required field. In this case add ag_catalog in the search_path var.
Save the file and restart server.
Note: Sometimes this does not work even when the file is changed so you’ll have to find another method in that case.