IBM Cloud Docs
Running SQL queries

Running SQL queries

SQL is a standardized language for defining and manipulating data in a relational database. You can use the Query workspace interface in IBM® watsonx.data to run SQL queries and scripts against your data.

The Query workspace has the following components:

  • Data objects: To view the engines, catalogs, schemas, tables, and columns.

  • Engine: To select an engine and view the associated catalogs.

  • Saved queries: To view the saved queries.

  • Worksheet: To write SQL queries.

The Query workspace page provides basic options to undo, redo, cut, copy, paste, save, clear, and delete.

Format selection option is enabled only when an SQL statement in a query worksheet is selected. The Format worksheet option formats all the content in the worksheet. Comment selection is used to explain sections of SQL statements.

The Delete option is enabled only after an SQL query is saved.

To run the SQL queries, do the following steps:

  1. Log in to the watsonx.data console.

  2. From the navigation menu, select SQL. The Query workspace page opens.

  3. Select an engine from the Engine drop-down.

  4. Select the catalog, schema, table, or column in which you want to run the query.

  5. Click the overflow menu and select the required query.

    • For a catalog and schema, you can run the Generate Path query.
    • For a table, you can run the Generate path, Generate SELECT, Generate ALTER, and Generate DROP query.
    • For a column, you can run the Generate path, Generate SELECT, and Generate DROP query.
  6. Click the Save icon to save the query. A Save query confirmation dialog appears.

  7. Click Save.

  8. Click the Run button to run the query. Using Run to cursor or Run from cursor, you can run queries from or until your cursor position.

  9. Select Result set or Details tab to view the results. You can export the result as a csv file using Export to CSV icon.

  10. Click Saved queries to view the saved queries.

    SQL statements within worksheets can be shared with all users who have access to the instance. These statements could be viewed, edited, or deleted by any of these users.

  11. Click Explain to view the logical or distributed plan of execution for a specified SQL query.