Select a documentation version: <button class="button button-with-icon cloud-select-dropdown__button button-primary" aria-haspopup="true">15.5.2</button>

- [16.3.0](https://docs.cloud.google.com/alloydb/omni/kubernetes/16.3.0/docs/install-orafce.md.txt)
- [15.7.1](https://docs.cloud.google.com/alloydb/omni/kubernetes/15.7.1/docs/install-orafce.md.txt)
- [15.7.0](https://docs.cloud.google.com/alloydb/omni/kubernetes/15.7.0/docs/install-orafce.md.txt)
- [15.5.5](https://docs.cloud.google.com/alloydb/omni/kubernetes/15.5.5/docs/install-orafce.md.txt)
- [15.5.4](https://docs.cloud.google.com/alloydb/omni/kubernetes/15.5.4/docs/install-orafce.md.txt)
- [15.5.2](https://docs.cloud.google.com/alloydb/omni/kubernetes/15.5.2/docs/install-orafce.md.txt)

<br />

AlloyDB Omni does not include the Orafce extension, but you can manually add it to an existing AlloyDB Omni installation by following the instructions on this page.

<br />

## Before you begin

Ensure that you meet the following system requirements:

- You've [installed AlloyDB Omni](https://docs.cloud.google.com/alloydb/omni/kubernetes/15.5.2/docs/install.md.txt)
  on your system.

- You've [installed the AlloyDB Omni
  CLI](https://docs.cloud.google.com/alloydb/omni/kubernetes/15.5.2/docs/omni-cli) on your system.

## Add Orafce to your AlloyDB Omni installation

To add the Orafce extension to your AlloyDB Omni installation,
follow these steps:

1. Find your installed AlloyDB Omni version labels:

   ```
   sudo alloydb version
   ```

   The output is similar to the following:

   ```
   AlloyDB Omni CLI version: 1.0
   AlloyDB Omni database server version: 15.5.2
   ```

   Take note of the database server version number; you need it in the next step.
2. Set the `OMNI_VERSION` environment variable:

   ```bash
   OMNI_VERSION=VERSION
   ```

   Replace <var translate="no">VERSION</var> with the complete database server version
   from the previous step---for example, `15.5.2`.
3. Create a new AlloyDB Omni container that includes Orafce:

       mkdir ~/alloydb-omni-orafce
       tee -a ~/alloydb-omni-orafce/Dockerfile << EOF
       ARG OMNI_VERSION

       FROM postgres:15-bookworm as postgres

       RUN apt-get update && \
               apt-get install -y --no-install-recommends \
               postgresql-15-orafce && \
               apt-get purge -y --auto-remove && \
               rm -rf /var/lib/apt/lists/*

       FROM gcr.io/alloydb-omni/pg-service:${OMNI_VERSION}

       COPY --from=postgres /usr/lib/postgresql/15/lib/orafce.so /lib/orafce.so
       COPY --from=postgres /usr/share/postgresql/15/extension/orafce* /share/extension/

       COPY --from=postgres /usr/lib/x86_64-linux-gnu/ /usr/lib/x86_64-linux-gnu/
       COPY --from=postgres /lib/x86_64-linux-gnu/ /lib/x86_64-linux-gnu/
       EOF

       cd ~/alloydb-omni-orafce

       sudo docker build --build-arg OMNI_VERSION=$OMNI_VERSION --tag gcr.io/alloydb-omni/pg-service-with-orafce:$OMNI_VERSION .

4. Stop the database server:

   ```
   sudo alloydb database-server stop
   ```
5. Open `/var/alloydb/config/dataplane.conf` in a text editor.
6. Modify the line that defines the `PG_IMAGE` variable so that it refers to the container that you built in a previous step:

   ```
   PG_IMAGE=gcr.io/alloydb-omni/pg-service-with-orafce
   ```
7. Start AlloyDB Omni:

   ```
   sudo alloydb database-server start
   ```
8. Connect to your database:

   ```
   sudo docker exec -it pg-service psql -h localhost -U postgres
   ```
9. Enable Orafce:

   ```sql
   CREATE EXTENSION IF NOT EXISTS ORAFCE;
   ```
10. Confirm that Orafce is installed and enabled:

    ```sql
    SELECT oracle.sysdate();
    ```

> [!NOTE]
> **Note:** Due to some known issues with the Orafce extension on AlloyDB Omni, we do not recommend using `dbms_utility.format_call_stack` and `dbms_output.get_line` functions.