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

Relevant Blogs

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...
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

More Blogs

Highlights from the PostgreSQL 16 Beta Release

The PostgreSQL Global Development Group released PostgreSQL 16 Beta 1 on May 25, 2023. PostgreSQL 16 improves logical replication by enabling replication from standbys as well as the ability to...
June 02, 2023