When working with databases, a crucial aspect of user interaction involves writing and executing SQL queries. In SQL Editor, they can create and manage SQL documents and subsequently execute them against the connected database server.
To create a new SQL document:
1. On the standard toolbar, click New SQL.
2. In the Connect to Server window that opens, choose the server you want to connect to or create a new one, and click Connect.
The empty SQL document opens where you can create or update a SQL statement.
Each SQL document includes different representations of the content: Text and Data document views.
To switch to a specific view, click the view name at the bottom panel of the document.
In the SQL Editor, the query execution results can be represented as a grid (default state) and as cards.
To represent results as a grid, click Switch to Grid View on the SQL Editor toolbar.
In the grid view, you can group the execution results by box. To do this, click Show Group by Box and drag a column header to the corresponding area:
The query execution results will look as follows:
To view the results as cards, click Switch to Card View on the SQL Editor toolbar.
SQL document has two types of view layout: Split Layout (default layout) and Combined Layout. To switch between document layouts, use the corresponding options at the bottom-right corner of the document.
In the split layout, a document is divided into two horizontal areas:
1. Text - the SQL document you are working with.
2. Data - the query execution result.
A document has the main view, which is aligned to the top of the document viewport, and additional views, which are displayed at the bottom area of the document view.
To change the main document view, click Swap main and additional document views at the bottom of the SQL document.
In the combined layout, you can see only one view at a time.
To switch between the document views, click Text or Data at the bottom of the SQL document.
SQL code can be selected in the following ways:
dbForge Data Compare allows adding a bookmark to any part of a SQL document. This feature saves a particular line in the code and the cursor position.
To add a bookmark, on the standard toolbar, click Toggle a bookmark on the current line or press Ctrl+K, K.
To navigate the bookmarks:
To delete bookmarks in the current document, click Clear all bookmarks in the current document or press Ctrl+K, L.
If you are working with a large script, you might need to collapse some of the clauses for convenience. Hovering over the collapsed clause will display its content.
The status bar contains the most important information regarding the current connection and query execution.
Environment Category | Connection Status | Host (Server version) | Username | Selected Database |
When you execute a query, the query execution status and the query execution time will be displayed in the status bar.
Environment Category | Query Execution Status | Execution Time | Host (Server version) | Username | Selected Database |
To comment on the part of the SQL code, select it and click Comment out the selected lines on the standard toolbar. Alternatively, press CTRL+K, C. To uncomment a section, select it and click
Uncomment the selected lines on the standard toolbar or use the CTRL+K, U keyboard shortcut.