DataGrip
 
Get DataGrip
You are viewing the documentation for an earlier version of DataGrip.

Context live templates

Last modified: 05 September 2023

Context live templates is a solution for anyone who wants to generate simple statements straight from the Database Explorer. While live templates cover many cases where you need to write a simple query, context live templates take into account the context of the database explorer and the data source that you are using.

In the following animation, we use the Select first N rows from a table context live template for PostgreSQL, Microsoft SQL Server, and MySQL. Depending on a table of a data source, DataGrip generates different queries.

https://resources.jetbrains.com/help/img/idea/2023.2/db_context_live_templates.png
Gif

In contrast to regular live templates, context live templates use dbObjectName and dbColumns expressions for template variables and are applied to the Any SQL Statement context. For more information about template variables, refer to Live template variables.

Context live templates also work from the data editor. If you are working with a table and you wish to query it, you can the SQL scripts action and select the template that you need.

https://resources.jetbrains.com/help/img/idea/2023.2/db_context_live_templates_from_data_editor.png
Gif