• Beta
SQL Editor
  • 16 Jan 2021
  • 2 Minutes To Read
  • Contributors
  • Print
  • Share
  • Dark
    Light

SQL Editor

  • Print
  • Share
  • Dark
    Light

Browsing to the SQL Editor

In the Toolbar, simply select SQL Lab and, in the drop-down menu, select SQL Editor.

2021-01-16-SQL Lab Menu.png


Schema Navigator

Browse to and select different schema within the datasource, provided that Expose in SQL Lab is enabled in the database.

2021-01-16_Schema_Navigator.png


Multi-tab Queries

Multiple tabs for each query enable you to easily switch between different queries within one interface.

2021-01-16_13-47-57.png


SQL Editor Panel

The SQL Editor panel allows different data source semantics / comments and runs one query at a time.

2021-01-16_13-48-41.png


SQL Manager Bar

Enables you to manage your query work with common tools, such as run, save, share, and an auto-completion toggle. The Parameters button enables you to use the Jinja templating syntax to assign a set of parameters as JSON.

2021-01-16_13-49-28.png


Results Tab

View the results of your queries here. Tools include:

  • Explore: Open the table view chart with the run query.
  • CSV: Save data in a CSV file.
  • Clipboard: Copy data to your systen's clipboard.

2021-01-16_13-51-52.png

Considerations when Running Queries

Some items to keep in mind when running queries in the SQL Editor:

  • Even if the SQL Editor has several queries, only one query result will be showed (the last one);
  • A query could timeout if it did not return values from the database (the default waiting time is 6 hours) or if the web server request timed out;
  • Queries limit the number of rows that are retrieved from the database. This is because:
    • It is an unnecessary overhead to bring in a lot of data from the database;
    • Limiting the number of rows prevents long-running queries in the database; and,
    • To avoid the accidental selection of Select * From with a table comprised of millions of rows, which could halt the database.

Create Table As (CTAS)

The CTAS button—found in the SQL Manager Bar—is used to materialize a query to a singular table in order to avoid complex joins or aggregations that can affect performance.

Access to this feature is controlled via the Edit Record tool when viewing a list of databases. Simply select the Allow CREATE TABLE AS checkbox to enable this feature. In addition, the CTAS Schema field enables you to create a new CTAS table in a specified schema.

2021-01-16_13-54-07.png


Query History Tab

The Query History panel, as the name implies, shows a history of all previously run queries and conveys basic information, such as success/failure, start time, duration, progress (if still running), and so on.

2021-01-16_13-55-35.png

Of particular note is the actions column, which enables you to do the following:

  • Edit (pencil icon): Enables you to edit the query.
  • New Tab (plus icon): Creates a new tab featuring the query.
  • Trash Bin: Removes the query from the history log.
Was This Article Helpful?