SQL Editor
Altova website: SQL editor
The SQL Editor is the area where you can create, display, edit, and execute the SQL statements that are required for your database work. You can save SQL scripts that you have created in the SQL Editor and add them to your project. In addition, you can also open existing SQL files and display them in the SQL Editor.
The SQL Editor is started automatically when you open an SQL file or generate a statement from an existing database object. Apart from that, you can always open a new SQL Editor window as follows:
•Click the SQL Editor icon in the Standard toolbar, or select the menu option File | New | SQL Editor, or press Ctrl+N.
As soon as an SQL Editor window is active, the SQL Editor menu and toolbars are available. In addition, each SQL Editor window has a toolbar of its own which provides buttons for executing SQL as well as various text selection and display options discussed further in this chapter.
Note: | A new SQL Editor window is automatically associated with the data source that is active in the Online Browser or Project Window. The active data source is displayed at all times in the Execution Target Bar. That is, all commands issued from SQL Editor will affect this particular data source only. If there are multiple data sources, the SQL Editor belongs to the one which was last clicked before you opened the SQL Editor. Any subsequent SQL Editor windows that you open will inherit the currently active data source. |
If there is no data source connected, the SQL Editor window is in the "Offline" state. You can easily change the data source to which the SQL Editor window is connected, as shown below.
To assign a data source to an SQL Editor window:
1.Click into the SQL Editor window whose properties you want to change.
2.In the Properties window, select the data source, and, if applicable, the root object.
To jump to the Properties window, click the Unknown or Offline hyperlinks in the Execution Target Bar (provided that the Show/Hide Execution Target Bar button is toggled on). In the image below, no data source is assigned yet to the SQL Editor window, which is why the Execution Target bar displays "Unknown - Offline" as execution target.
You can edit SQL statements in the SQL Editor like in any other text editor using the standard text manipulation commands such as Copy (Ctrl + C), Paste (Ctrl + V), and Cut (Ctrl + X). In addition, the SQL Editor provides features such as syntax coloring, comments, bookmarks, regions, and text highlighting (see SQL Editor Features). Also, the SQL Editor provides advanced Find and Replace functionality, including the ability to search and replace using regular expressions (see Finding and Replacing Text).
The auto-completion feature can assist you with entering statements into SQL Editor (see Auto-completion). You can also drag existing database objects into the SQL Editor window to create SQL statements automatically (see Generating SQL Statements).
Support for syntax coloring, text auto-completion, and formatting in SQL Editor may vary depending on the database version. More recent database versions typically provide better support for these features. |
When SQL Editor contains multiple statements, you can choose to execute them in bulk, if supported by the database type or driver, or sequentially, see Executing SQL. It is also possible to give custom descriptive names to the resulting tabs, see Naming Result Tabs.
The appearance of SQL statements in the SQL Editor can be configured in the SQL Formatting Configurations dialog box. For example, you can configure to generated SELECT statements so that a line break should always occur before each FROM keyword. The formatting syntax can be fine-tuned not only for each database kind, but also at statement level, see Formatting SQL.
When you need to export only a subset of data from the database, you can write or generate the required SELECT statement in the SQL Editor, and then proceed to exporting results (see Selecting Data for Export). SQL Editor can also be used to create views directly from SQL statements, see Creating Views.
The text displayed in the SQL Editor can be printed and also previewed before printing (see Printing SQL).