• No results found

Query Editor

Navicat provides a useful tool called Query Editor for creating and executing queries. It allows you to create and edit SQL text for a query, prepare and execute selected queries.

Hint: Query text will be automatically generated while you build in Query Builder.

You are allowed to run selected portion of query, just simply control-click the highlighted query and select Run

Selected.

You can define multiple SQL statements in one Editor window, and the editor let you run the current statement your cursor is on (place your cursor in the front of the desired statement). Just simply select Run Statement From Here.

Note: Select Run Statement From Here, the next statement will continue to run.

Editor Advanced Features

Navicat provides a wide range advanced features, such as compelling code editing capabilities, smart code-completion, sql formatting, and more.

SQL Formatting

Upper Case Keywords

Format the SQL keywords in the selected statement to upper case.

Comment

Comment the selected lines of codes.

Uncomment

Uncomment the selected lines of codes.

Beautify SQL With (Available only in Full Version)

Change the Beautify SQL settings.

Option Description

Use tab character Check this option to use tab character. Tab Size Set the tab size.

Short Brace Length Set the length of the short brace.

Upper case keywords Format all the SQL keywords to upper case.

Beautify SQL (Available only in Full Version)

Format the selected codes with the Beautify SQL settings.

Minify SQL (Available only in Full Version)

Minify the format of the SQL in the SQL Editor.

Code-Completion (Available only in Full Version)

Code-completion in Navicat displays information in drop-down menus as you type your SQL statement in the editor, it assists you with statement completion and the available properties of database objects, for example databases, tables, fields, views etc with their appropriate icons.

To activate the code-completion, just simply press '.' for the available properties of database object currently in the scope.

Hint: Smart code-completion will pop up a list of variants for the word completion automatically.

Note: Code-completion can be also applied on View, Functions/Procedures, etc. Related topic:

Preferences

Code Folding

Code folding feature enables you to collapse blocks of code such that only the first line of the block appears in Editor.

A block of code that can be folded is indicated by and to the left of the first line and the last line of the block. In contrast, a folded block of code is indicated by an icon to left of the code block. You can fold the block by clicking

or or expand it by clicking in Editor.

Brace Highlight

Navicat supports to highlight the matching brace in the editor, i.e. ().

Note: The cursor must be on a brace to show the highlight.

Find and Replace

The Find Dialog is provided for quick searching and replacing for the text in the editor window. Just simply click Edit ->

Find -> Find from the menu or press CMD-F and enter a search string.

Incremental searching is used here. As you type, the matched text is found and highlighted instantly. This saves your time from typing the entire text.

The search starts at the cursor's current position to the end of the file.

If you want to search a text that has been searched before, you can open the drop-down menu by clicking where a list of searching history will be displayed.

Find & Replace

To open the Replace bar, simply check the Replace box and enter the text you want to search and replace.

Click All to replace all occurrences automatically.

Click Replace to replace the first occurrence.

You can choose to perform either String Matching or Regular Expression for Find and Find & Replace. There are some additional options:

Ignore Case Disable case sensitive search.

Wrap Around Select to continue searching from beginning of the query when you start the search somewhere within the query editor.

Whole Words Return the objects that match the entire word of the search string.

Copy with Quotes

To copy the SQL statement with quotes, just simply control-click the highlighted SQL. Then, select Copy with quotes and choose the format.

Navicat has the ability to zoom in or zoom out the SQL in the editor. The zooming options are available from the Edit menu. The same effect can be achieved with keyboard shortcuts.

 Zoom In: [CMD-+]

 Zoom Out: [CMD--]

 Reset: [CMD-0]

Hint: Range from -4 to +5.

Note: Files are opened in different tabs will not be effected by the zoom.

Query Results

To run the query, click Run on the toolbar. If the query statement is correct, the query executes and, if the query statement is supposed to return data, the Result tab opens with the data returned by the query. If an error occurs while executing the query, execution stops, the appropriate error message is displayed.

The Result tab displays the result data, returned by the query, as a grid. Data can be displayed in two modes: Grid

View and Form View. See Table Viewer for details.

Hint: Navicat supports to return 10 resultsets.

Note: You can choose to show the Result tab below the editor or in a new tab by selecting Edit -> Show Result ->

Below Query Editor or In a New Tab.

Query Profile and Status (Available only for MySQL and MariaDB)

To show the profile and status when running the query, simply choose Edit -> Show Profile and Status and click

Run on the toolbar.

The Profile tab displays the query profile: Table lock, System lock, Statistic, etc.

Note: For MySQL 5.0, support from 5.0.37 or above. For MySQL 5.1, support from 5.1.24 or above.

The Status tab displays the query status: Bytes received, Bytes sent, etc.