How do I save a query in pgAdmin 4?

How do I save a query in pgAdmin 4? No matter where I try to save it within the PostgreSQL file or the pgAdmin 4 file, the result is that I do not have access.

C:\Program Files\PostgreSQL\9.6\pgAdmin 4\

I have tried both bin files, data files, and many other files.

It always says that I don't have access.

I see that I can save data output as a CSV file, but I want the actual query.

If I close pgAdmin, I lose everything in the query.


Solution 1:

I assuming that query means that you type query in Query tool.

Default location: C:\Users\YOUR_USERNAME_HERE\AppData\Roaming\pgAdmin\storage

enter image description here

enter image description here

Solution 2:

Generally when we click the save button a window is opened(look at fig1). We can see that create option is disabled.

What to do? Just write the file_name.sql at that address(look at fig2). We can see that create option is enabled. Click on create button to save.

Solution 3:

You have to write the file name in the location. For example: C:\Users\YOUR_USERNAME_HERE\AppData\Roaming\pgAdmin\storage\query1.sql