Using the VQL Shell

With the VQL Shell tool you can execute any VQL statement, including queries and DDL statements (CREATE VIEW, DROP VIEW, etc.). To execute several statements at once, separate them with ;. You can enter them or load them from a file with the button “Load”.

The VQL Shell has several controls, many of them self-explanatory. This list contains the ones that need some clarification:

  • Execute. Executes all the queries of the box. To execute only part of what you entered in the queries box, select that part and press Ctrl+Enter.

  • Load. Loads the content of a file into the commands box. To load a VQL file that creates several databases, do it from the “Import” wizard on the File menu instead of from the VQL Shell. The reason is that the “Import” wizard is capable of importing correctly elements of a database that depend on elements of another database.

  • Limit Rows. If selected, the Tool only displays the first N rows of the result but retrieves the entire result set of the query. This is useful to measure how long does it take to run a query but do not want display all the results (e.g. if the query returns millions of rows)

  • Stop query when the limit is reached. If selected, the Tool adds the clause LIMIT to the query sent to the Server. E.g. if you execute the query SELECT * FROM view, the Tool sends the query SELECT * FROM view LIMIT 100. That means that the query will finish after processing 100 rows.

    If this check box is cleared, the Tool does not display more rows than “Limit rows”, but the Tool keeps processing the rest of the result set.

  • Press Ctrl+F to open a find and replace dialog.

When executing a query, the Tool will show the Query Results tab. In this tab you can do the following:

  • Click Save to store the result of the query to a CSV file. Note that this only saves the data that the administration tool is showing. For example, if Limit rows is selected and the limit is 150 but the query returns 200 rows, the Tool will only save those 150 rows.
  • See the Execution Trace of the query. The section Execution Trace of a Statement explains the elements displayed in the execution trace of a query.

The VQL Shell includes a “command log” that saves the last VQL statements run. This command log is maintained between several executions of the Administration Tool. You can see it in the tab Execution Log.

You can use the Server Explorer to speed up writing VQL statements:

  • Drag an element to add its name to the current VQL statement.
  • Right-click on a view and click VQL Shell > Select… to add the statement SELECT <fields of the view> FROM <view name>.
  • Right-click on any element and click VQL Shell > Desc… to add the statement DESC VQL <element type> <element name>.