Apache Ignite SQL Documentation

The Apache Ignite SQL Developer Hub

Welcome to the Apache Ignite SQL developer hub. You'll find comprehensive guides and documentation to help you start working with Apache Ignite SQL as quickly as possible, as well as support if you get stuck. Let's jump right in!

Get Started    

Schemas

Everything you need to know about SQL schemas in Ignite

Ignite has a number of default schemas and allows users to create custom schemas for better organization of their tables.

There are two schemas that are available by default:

  • The SYS schema, which contains a number of system views with information about cluster nodes. Refer to the SYS Schema page for further information.
  • The PUBLIC schema, which is used by default whenever schema is not specified.

Custom schemas are created in the following cases:

  • Ignite creates schemas specified in the configuration. See Custom Schemas.
  • Ignite creates a schema for each cache created via one of the programming interfaces or XML configuration. See Cache and Schema Names.

Custom Schemas

Custom Schemas can be set via the sqlSchemas property of IgniteConfiguration. You can specify a list of schemas in the configuration before starting your cluster and then create objects in these schemas at runtime.

Below is a configuration example with two custom schemas.

<bean class="org.apache.ignite.configuration.IgniteConfiguration">
    <property name="sqlSchemas">
        <list>
            <value>MY_SCHEMA</value>
            <value>MY_SECOND_SCHEMA</value>
        </list>
    </property>
</bean>
IgniteConfiguration cfg = new IgniteConfiguration();

cfg.setSqlSchemas("MY_SCHEMA", "MY_SECOND_SCHEMA");

To connect to a specific schema via, for example, a JDBC driver, provide the schema name in the connection string:

jdbc:ignite:thin://127.0.0.1/MY_SCHEMA

PUBLIC Schema

The PUBLIC schema is used by default whenever schema is required and is not specified. For example, when you connect to the cluster via JDBC without setting the schema explicitly, you will connect to the PUBLIC schema.

Cache and Schema Names

When you create a cache (in the configuration or via available programming interface), you can manipulate the cached data using the SQL API. In SQL terms, each cache corresponds to a separate schema whose name equals the name of the cache.

Similarly, when you create a table via SQL API, you can access it as a key-value cache via the programming interfaces. The name of the corresponding cache can be specified by providing the CACHE_NAME parameter in the with part of the CREATE TABLE statement.

CREATE TABLE City (
  ID INT(11),
  Name CHAR(35),
  CountryCode CHAR(3),
  District CHAR(20),
  Population INT(11),
  PRIMARY KEY (ID, CountryCode)
) WITH "backups=1, CACHE_NAME=City";

See the CREATE TABLE section for more details.

If you do not use this parameter, the cache name is defined in the following format:

SQL_<SchemaName>_<TableName>

Updated 4 months ago

Schemas


Everything you need to know about SQL schemas in Ignite

Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.