A newer version of Management Center is available.

View latest

Executing SQL Queries

You can use Management Center to execute SQL queries on a Hazelcast cluster.

Before you Begin

If a map contains domain objects, the classes for those objects must be on the classpath of Management Center before you can query them. See the Providing an Extra Classpath.

Using the SQL Browser

Click SQL Browser in the toolbar.

SQL Browser Window

To query an existing map in the cluster, select the map’s name from the dropdown:

  • If the map does not have a mapping, an autogenerated CREATE MAPPING statement is inserted into the editor. This statement maps the data structure to a table that Hazelcast can access.

  • If the map already has a mapping, an autogenerated SELECT statement is inserted into the editor.

To execute a query, click Execute Query.

SQL Browser listing maps

After a successful query execution, you will see the results under Query Results in two formats:

  • As a plain list, where the __key and this columns represent the map entries' keys and values.

  • As JSON, where the same data is represented in JSON format.

Example query results

A list of query results

Exporting Query Results as a CSV file

You can use Export as CVS to export the query result as a CSV file in a format RFC 4180.

Here is an example JSON view of the same query results:

JSON query results

To copy the result to the clipboard, use the Copy to Clipboard button in the top right corner.

Viewing Executed SQL Queries

In the History tab, you can see the history of query execution. The history holds the last one hundred executed queries. Each row contains Execution Time, Execution Status and Query values. You can re-execute any query from the history by pushing a button in the Execute column.

A history of executed queries

You can also use Clear Query Result to remove the query results from both the list and JSON views.

Creating a Map

  1. Open the SQL browser and execute the following SQL statement to create a map called my_first_map.

    CREATE MAPPING my_first_map TYPE IMap OPTIONS ('keyFormat'='varchar','valueFormat'='varchar');
  2. Delete the above statement and now execute the following.

    SINK INTO my_first_map VALUES
    ('1', 'John'),
    ('2', 'Mary'),
    ('3', 'Jane');
  3. Close the SQL browser and go to Storage > Maps to verify that my_first_map is created.

    Map is Created using SQL Browser

Next Steps

If you’re interested in learning more about SQL in Hazelcast, see the SQL reference in the Platform documentation.