> ## Documentation Index
> Fetch the complete documentation index at: https://docs.cube.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Oracle

> The driver for Oracle is community-supported and is not maintained by Cube or the database vendor.

> [!WARNING]
>
> The driver for Oracle is community-supported and is not maintained by Cube or the database vendor.

## Prerequisites

* The hostname for the [Oracle][oracle] database server
* The username/password for the [Oracle][oracle] database server
* The name of the database to use within the [Oracle][oracle] database server

> [!NOTE]
>
> The driver uses \[`node-oracledb`]\[node-oracledb] in Thin mode, which supports Oracle Database
> 12.1 and later. Older servers (e.g. 11g) require \[Thick mode]\[node-oracledb-thick], which the
> driver does not currently enable — [track this issue](https://github.com/cube-js/cube/issues/10756).

## Setup

### Manual

Add the following to a `.env` file in your Cube project:

```dotenv theme={"dark"}
CUBEJS_DB_TYPE=oracle
CUBEJS_DB_HOST=my.oracle.host
CUBEJS_DB_NAME=my_oracle_database
CUBEJS_DB_USER=oracle_user
CUBEJS_DB_PASS=**********
```

## Environment Variables

| Environment Variable | Description | Possible Values | Required |
| - | - | - | :-: |
| [`CUBEJS_DB_HOST`](https://docs.cube.dev/reference/configuration/environment-variables#cubejs_db_host) | The host URL for a database | A valid database host URL | ✅ |
| [`CUBEJS_DB_PORT`](https://docs.cube.dev/reference/configuration/environment-variables#cubejs_db_port) | The port for the database connection | A valid port number | ❌ |
| [`CUBEJS_DB_NAME`](https://docs.cube.dev/reference/configuration/environment-variables#cubejs_db_name) | The name of the database to connect to | A valid database name | ✅ |
| [`CUBEJS_DB_USER`](https://docs.cube.dev/reference/configuration/environment-variables#cubejs_db_user) | The username used to connect to the database | A valid database username | ✅ |
| [`CUBEJS_DB_PASS`](https://docs.cube.dev/reference/configuration/environment-variables#cubejs_db_pass) | The password used to connect to the database | A valid database password | ✅ |
| [`CUBEJS_DB_SSL`](https://docs.cube.dev/reference/configuration/environment-variables#cubejs_db_ssl) | If `true`, enables SSL encryption for database connections from Cube | `true`, `false` | ❌ |
| [`CUBEJS_DB_MAX_POOL`](https://docs.cube.dev/reference/configuration/environment-variables#cubejs_db_max_pool) | The maximum number of concurrent database connections to pool. Default is `8` | A valid number | ❌ |
| [`CUBEJS_CONCURRENCY`](https://docs.cube.dev/reference/configuration/environment-variables#cubejs_concurrency) | The number of [concurrent queries][ref-data-source-concurrency] to the data source | A valid number | ❌ |

[ref-data-source-concurrency]: https://docs.cube.dev/admin/connect-to-data/concurrency.md#data-source-concurrency

## Pre-Aggregations

By default, pre-aggregations are [stored in Cube Store][ref-preaggs-storage] and
need no setup in Oracle. Pre-aggregations with `external: false` are built inside
Oracle, in a schema that you create first. Cube can't create it because an Oracle
schema is a user account.

1. Create a dedicated user for pre-aggregations. Replace `users` with the
   tablespace that should hold the pre-aggregation tables:

   ```sql theme={"dark"}
   CREATE USER cube_preaggs NO AUTHENTICATION
     DEFAULT TABLESPACE users QUOTA UNLIMITED ON users;
   ```

2. Let `CUBEJS_DB_USER` create, index, drop and read tables in that schema. On
   Oracle 23ai and later, grant this on that schema only:

   ```sql theme={"dark"}
   GRANT CREATE ANY TABLE, CREATE ANY INDEX, DROP ANY TABLE, SELECT ANY TABLE
     ON SCHEMA cube_preaggs TO oracle_user;
   ```

   Earlier releases only have database-wide `CREATE ANY TABLE`, `CREATE ANY INDEX`,
   `DROP ANY TABLE` and `SELECT ANY TABLE` privileges. They let the user read and
   drop tables in every schema.

3. Set [`CUBEJS_PRE_AGGREGATIONS_SCHEMA`](https://docs.cube.dev/reference/configuration/environment-variables#cubejs_pre_aggregations_schema)
   to that user, e.g., `cube_preaggs`.

> [!WARNING]
>
> Use this schema only for pre-aggregations. Every build drops the tables in it that are not
> current pre-aggregation tables, so never point it at a schema that holds your data.

## SSL

To enable SSL-encrypted connections between Cube and Oracle, set the
[`CUBEJS_DB_SSL`](https://docs.cube.dev/reference/configuration/environment-variables#cubejs_db_ssl) environment variable to `true`. For more information on how to
configure custom certificates, please check out [Enable SSL Connections to the
Database][ref-recipe-enable-ssl].

[oracle]: https://www.oracle.com/uk/index.html

[node-oracledb]: https://node-oracledb.readthedocs.io/en/latest/user_guide/introduction.html#architecture

[node-oracledb-thick]: https://node-oracledb.readthedocs.io/en/latest/user_guide/initialization.html#enabling-node-oracledb-thick-mode

[ref-recipe-enable-ssl]: https://docs.cube.dev/recipes/configuration/using-ssl-connections-to-data-source.md

[ref-preaggs-storage]: https://docs.cube.dev/docs/pre-aggregations/using-pre-aggregations.md#pre-aggregations-storage


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.