Skip to content
EDB
Upcoming Webinar: What’s New in PostgreSQL 15 • Dec 7 • Register Now

Blog

How To Use Autocomplete Feature in Query Tool

Akshay Joshi6/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.

Akshay Joshi is a Principal Software Architect at EDB. He joined in 2010 and works primarily on monitoring tools for PostgreSQL. He has been actively involved with pgAdmin since 2011 and he is one of the core committers, release manager of the pgAdmin open source project. His areas of expertise incl ...