Thursday, February 01, 2024

DataGrip with parametrized SQL queries

 User Parameters | DataGrip Documentation


Open settings by pressing Ctrl+Alt+S and navigate to Database | Query Execution | User Parameters.


Substitute inside SQL strings

Apply parameter patterns to string literals in the SQL code.

For example, consider the following code.

SELECT ${column_name}
FROM actor
WHERE actor_id='${actor_id}'


even this works

SELECT * FROM table WHERE column = :value

sql - How to run query with parameters in DataGrip? - Stack Overflow

Just run it via Ctrl+Enter!  (command+return on Mac keyboard)



No comments: