# Creating and configuring the source database user

This is the Oracle user that connects to the source database.

The source database user can be the same as the schema of the data. However, we recommend that you create a Tonic Structural-specific user that has more restricted access.

To create the source database user, use the following set of steps:

1. [Create the source database user](#oracle-source-user-create)
2. [Grant basic privileges to the user](#oracle-source-user-basic-privs)
3. [Grant access to system catalog views](#oracle-source-user-catalog-views)
4. [Grant access to source database tables](#oracle-source-user-source-tables)
5. [Grant access to packages](#oracle-source-user-packages)

## Creating the source database user <a href="#oracle-source-user-create" id="oracle-source-user-create"></a>

To create the source database user:

```
CREATE USER tonic IDENTIFIED BY "<tonic password>";
```

## Granting basic privileges to the source database user <a href="#oracle-source-user-basic-privs" id="oracle-source-user-basic-privs"></a>

To grant basic privileges to the source user:

```
GRANT CREATE SESSION TO tonic;
```

## Granting the source database user access to system catalog views <a href="#oracle-source-user-catalog-views" id="oracle-source-user-catalog-views"></a>

For information on options for granting access to system catalog views, go to [oracle-database-user-sys-catalog](https://docs.tonic.ai/app/setting-up-your-database/oracle/oracle-before-workspace-creation/oracle-database-users/oracle-database-user-sys-catalog "mention").

## Granting the source database user access to source tables <a href="#oracle-source-user-source-tables" id="oracle-source-user-source-tables"></a>

The source database user must be able to select data from the tables.

To grant the required access, you can either:

* Grant `SELECT ANY TABLE` to the user
* Grant `SELECT` access to the individual tables in the source database

To grant `SELECT ANY TABLE`:

```
GRANT SELECT ANY TABLE TO tonic;
```

To grant `SELECT` access to the individual tables in the database:

{% code overflow="wrap" %}

```
BEGIN
    FOR x IN (SELECT owner, table_name FROM all_tables WHERE owner = '<source_schema>')
    LOOP
        EXECUTE IMMEDIATE 'GRANT SELECT ON "' || x.owner || '"."' || x.table_name || '" TO tonic';
    END LOOP;
END;
```

{% endcode %}

## Granting the source database user access to packages <a href="#oracle-source-user-packages" id="oracle-source-user-packages"></a>

### DBMS\_RANDOM

The source database user must be granted `EXECUTE ON` access to `DBMS_RANDOM`.

```
GRANT EXECUTE ON DBMS_RANDOM TO tonic;
```

### DBMS\_METADATA

If either:

* `TONIC_ORACLE_SKIP_CREATE_DB` is `true`
* The workspace overrides the setting to `true`

Then the source database user must have `EXECUTE ON` privileges for the `DBMS_METADATA` package:

```
GRANT EXECUTE ON DBMS_METADATA TO tonic;
```

### Other packages, based on object types

Depending on the object types that the source schema includes, the source database user must also have `EXECUTE ON` privileges for the following packages:

<table><thead><tr><th width="233.33984375" valign="top">Package</th><th valign="top">Object types that require it</th></tr></thead><tbody><tr><td valign="top"><code>DBMS_JAVA</code></td><td valign="top">JAVA CLASS<br>JAVA CLASS<br>JAVA RESOURCE<br>JAVA SOURCE</td></tr><tr><td valign="top"><code>DBMS_SCHEDULER</code></td><td valign="top">JOB<br>JOB CLASS<br>PROGRAM</td></tr><tr><td valign="top"><code>DBMS_MVIEW</code></td><td valign="top">MATERIALIZED VIEW</td></tr><tr><td valign="top"><code>DBMS_AQADM</code></td><td valign="top">QUEUE</td></tr></tbody></table>

To identify the types of objects that are present in the source schema, run the following:

{% code overflow="wrap" %}

```
SELECT object_type FROM dba_objects WHERE owner = '<source-schema>' ORDER BY object_type;
```

{% endcode %}

This access might already be in place for the `PUBLIC` user. If it is not, then to grant the access:

```
GRANT EXECUTE ON DBMS_JAVA TO tonic;
GRANT EXECUTE ON DBMS_SCHEDULER TO tonic;
GRANT EXECUTE ON DBMS_MVIEW TO tonic;
GRANT EXECUTE ON DBMS_AQADM TO tonic;
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.tonic.ai/app/setting-up-your-database/oracle/oracle-before-workspace-creation/oracle-database-users/oracle-source-user-create-config.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
