![]() This would name the result window with the comment. To differentiate between the result windows of queries, you can add comments to your queries by preceding text using ‘–’ (without the quotes). If you execute SQL queries often, this could be a good option to check out. In the preferences, you can modify the default behavior and specify whether you want IntelliJ IDEA to prompt you to select a query to run or run all queries, as well as other options. You can also format SQL queries using the regular IntelliJ IDEA ‘Reformat Code’ action. Of course, Alt+Enter can suggest and fix SQL statements. For example, it can highlight a subquery that needs an alias and is missing it. IntelliJ IDEA has inspections for SQL queries as well. ![]() IntelliJ IDEA and inspections for SQL Queries Max also showed how to multiple queries in the query console window and choose whether to execute some or all of them. Max showed how to write complex SQL queries very quickly in IntelliJ IDEA by using a combination of live templates, smart code completion, and abbreviation completion. So, for example, when searching for ‘actor_id’, you can type a shortened version of the name, such as simply ‘ai’. You can use abbreviations when working with completion. So, when you try to use a JOIN clause in your query, IntelliJ IDEA will suggest the complete join clauses. Moving beyond simple queries, Max showed how IntelliJ IDEA Ultimate understands the connections between your tables. When you execute a query, you can view the services window, which shows the console attached to your query and the time taken by the query execution. It was fascinating to see the magic of the wonder key combination Alt+Enter, in a query, say, ‘SELECT * FROM address’, which suggested that the * in the query could be replaced with the corresponding column list. We have a screencast and a blog on the various live templates that are available in IntelliJ IDEA, if you are interested. Max mentioned that you can create your own live templates using project settings. Code completion will let you select the table, view, or other entity names from a list of options. In the scratch file you just opened to write a query, you can use ‘sel’ and either press enter or tab to insert ‘SELECT * FROM ’. It is interesting to note that a lot of IntelliJ IDEA features, like Live Templates, are also available in the Database Tool Window. A console window is a scratch file attached to your data source. To execute queries, you can create a new query console by right clicking in the database tool window. Clicking on an entity like a table name will display all the table data. To search for any database entity in the Database tool window, you can just start typing the name you are looking for, including using short forms, just as you can in IntelliJ IDEA. He also used ‘Database Color Settings’ to change the background color of one of the databases to rose, making it easier to relate to. Max demonstrated how to group database connections, which can be very handy when you have multiple connections and you want to keep them together because of where they are used, test and production databases, for example. Max briefly explained various properties of a database connection – read only, transaction mode, run-keep alive query, auto-disconnect later, SSH and SSL, schemas to show in the database, advanced options on JDBC drivers. Max used PostgreSQL to demonstrate all the features of DataGrip, but he also noted that you would get the same functionality with the other databases. The database tool window has a database tree with many objects, and it also shows the active connections. IntelliJ IDEA can help you connect to a database, write queries, view data, manipulate it, and even export or import data. ![]() You can connect to many databases, like RedShift, Couchbase Query, H2, MondoDB, MySQL, Oracle, PostgreSQL, and many more. He demonstrated that the Database Tool Window can be used to view existing connections, rename them, or create new ones. ![]() ![]() He used an existing shortcut, which was being used by another window, but you can choose whatever works best for you. Max started his session by assigning a shortcut to the Database Tool Window, since it doesn’t have one by default. In fact, DataGrip functionality is supported by nearly all JetBrains IDEs, including PhpStorm and RubyMine. IntelliJ IDEA Ultimate includes nearly all DataGrip functionality. Maxim started his session by noting that DataGrip is a standalone JetBrains IDE for SQL and databases. He started with the basics of writing a simple query faster, and progressed to more complicated tasks like updating data, creating run configurations, and using language injections. On October 16, 2020, we hosted the live webinar ‘Working with SQL and Databases in IntelliJ IDEA’ by Maksim Sobolevskiy, Product Marketing Manager for Database Tools at JetBrains. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |