How To Use Autocomplete Feature in Query Tool

June 10, 2022

How to use autocomplete in Query Tool

To use autocomplete, begin typing your query; when you would like the query editor to suggest object names or commands that might be next in your query, press the Control + Space key combination. For example, type "SELECT * FROM " (without quotes, but with a trailing space), and then press the Control + Space key combination to select from a popup menu of autocomplete options.

Autocompletion for keywords

For keywords just type a few characters and press the Control + Space key combination.

Autocompletion for Keywords

Autocompletion of schema and schema objects

To use schema and its objects, type the schema name and ‘. ’ and press the Control + Space key combination.

Search path in the query tool

Search path in the query tool

Set search path in the Query Tool

In the previous example and screenshot you can not see the objects of ‘test_schema_diff’ until you type the schema name and ‘.’. Users can set the search path and then try the same ‘SELECT’ query. You will see all the objects of ‘test_schema_diff’ after setting the search path.

Set search path in the query tool

Autocompletion of joins

To use joins type the start of the query and press the Control + Space key combination.

Autocompletion of joins

Third party code used to implement autocomplete

pgAdmin 4 utilises the code from https://www.pgcli.com/ and modifies slightly to work as needed. Pgcli uses prompt_toolkit, and pgAdmin 4 integrates this code with the Code Mirror library to implement autocompletion. 

Conclusion

Use the autocomplete feature to write SQL commands more quickly by reducing the typing effort and providing quick access to the database object information.

Share this

More Blogs

PGVector as Embedding Store in PrivateGPT

EDB has a long history of open source contributions, and while we’re best known for our contributions to Postgres, that’s not the only project we contribute to. e.g Barman, CloudNativePG...
June 05, 2024

pgAdmin User Management in Server Mode

pgAdmin can be deployed as a web application by configuring the app to run in server mode. One can check out server deployment on how to run pgAdmin in server...
August 24, 2023

pgAdmin CI/CD

Almost exactly three years ago I wrote a blog on my personal page entitled Testing pgAdmin which went into great detail discussing how we test pgAdmin prior to releases. Back...
August 24, 2023