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

Explaining ABI Breakage in PostgreSQL 17.1

PostgreSQL comes out with a scheduled major release every year and scheduled minor releases for all supported versions every quarter. But in the November minor releases, two issues caused the...
December 06, 2024

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