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

- [Current (18.4.0)](https://docs.cloud.google.com/alloydb/omni/containers/current/docs/install-orafce.md.txt)
- [18.4.0](https://docs.cloud.google.com/alloydb/omni/containers/18.4.0/docs/install-orafce.md.txt)
- [18.3.0](https://docs.cloud.google.com/alloydb/omni/containers/18.3.0/docs/install-orafce.md.txt)
- [18.1.0](https://docs.cloud.google.com/alloydb/omni/containers/18.1.0/docs/install-orafce.md.txt)
- [17.10.0](https://docs.cloud.google.com/alloydb/omni/containers/17.10.0/docs/install-orafce.md.txt)
- [17.9.0](https://docs.cloud.google.com/alloydb/omni/containers/17.9.0/docs/install-orafce.md.txt)
- [17.7.0](https://docs.cloud.google.com/alloydb/omni/containers/17.7.0/docs/install-orafce.md.txt)
- [17.5.0](https://docs.cloud.google.com/alloydb/omni/containers/17.5.0/docs/install-orafce.md.txt)
- [16.14.0](https://docs.cloud.google.com/alloydb/omni/containers/16.14.0/docs/install-orafce.md.txt)
- [16.13.0](https://docs.cloud.google.com/alloydb/omni/containers/16.13.0/docs/install-orafce.md.txt)
- [16.11.0](https://docs.cloud.google.com/alloydb/omni/containers/16.11.0/docs/install-orafce.md.txt)
- [16.9.0](https://docs.cloud.google.com/alloydb/omni/containers/16.9.0/docs/install-orafce.md.txt)
- [16.8.0](https://docs.cloud.google.com/alloydb/omni/containers/16.8.0/docs/install-orafce.md.txt)
- [16.3.0](https://docs.cloud.google.com/alloydb/omni/containers/16.3.0/docs/install-orafce.md.txt)
- [15.18.0](https://docs.cloud.google.com/alloydb/omni/containers/15.18.0/docs/install-orafce.md.txt)
- [15.17.0](https://docs.cloud.google.com/alloydb/omni/containers/15.17.0/docs/install-orafce.md.txt)
- [15.15.0](https://docs.cloud.google.com/alloydb/omni/containers/15.15.0/docs/install-orafce.md.txt)
- [15.13.0](https://docs.cloud.google.com/alloydb/omni/containers/15.13.0/docs/install-orafce.md.txt)
- [15.12.0](https://docs.cloud.google.com/alloydb/omni/containers/15.12.0/docs/install-orafce.md.txt)
- [15.7.1](https://docs.cloud.google.com/alloydb/omni/containers/15.7.1/docs/install-orafce.md.txt)
- [15.7.0](https://docs.cloud.google.com/alloydb/omni/containers/15.7.0/docs/install-orafce.md.txt)
- [15.5.5](https://docs.cloud.google.com/alloydb/omni/containers/15.5.5/docs/install-orafce.md.txt)
- [15.5.4](https://docs.cloud.google.com/alloydb/omni/containers/15.5.4/docs/install-orafce.md.txt)
- [15.5.2](https://docs.cloud.google.com/alloydb/omni/containers/15.5.2/docs/install-orafce.md.txt)

<br />

<button value="debian" default="">Debian</button> <button value="ubi">UBI</button>

<br />

This page describes how to manually add the [orafce extension](https://github.com/orafce/orafce)
to an existing AlloyDB Omni installation. The orafce extension
provides functions and operators that emulate a subset of functions and packages
from the Oracle database. This extension simplifies migration of applications from
Oracle to PostgreSQL-compatible databases such as AlloyDB Omni.

## Before you begin

[Install AlloyDB Omni](https://docs.cloud.google.com/alloydb/omni/containers/16.8.0/docs/install.md.txt) 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:

   ### Docker

   ```bash
   docker run --rm -it  google/alloydbomni cat VERSION.txt
   ```

   ### Podman

   ```bash
   podman run --rm -it  google/alloydbomni cat VERSION.txt
   ```

   The output is similar to the following:

       AlloyDB Omni version: 16.8.0

   Take note of the AlloyDB Omni version number because you need it in the next step.
2. Create a new AlloyDB Omni container that includes orafce:

   ### Linux

   ```bash
   $ mkdir ~/alloydb-omni-orafce

   $ tee ~/alloydb-omni-orafce/Dockerfile << EOF
   ARG OMNI_VERSION
   FROM google/alloydbomni:${OMNI_VERSION}
   RUN apt-get update && \
         apt-get install -y --no-install-recommends postgresql-16-orafce && \
         apt-get purge -y --auto-remove && \
         rm -rf /var/lib/apt/lists/*
   EOF

   $ cd ~/alloydb-omni-orafce

   $ sudo docker build --build-arg OMNI_VERSION=OMNI_VERSION --tag google/alloydbomni-with-orafce:OMNI_VERSION .
   ```

   ### MacOS

   ```bash
   $ mkdir ~/alloydb-omni-orafce

   $ tee ~/alloydb-omni-orafce/Dockerfile << EOF
   ARG OMNI_VERSION
   FROM google/alloydbomni:OMNI_VERSION
   RUN apt-get update && \
         apt-get install -y --no-install-recommends postgresql-16-orafce && \
         apt-get purge -y --auto-remove && \
         rm -rf /var/lib/apt/lists/*
   EOF

   $ cd ~/alloydb-omni-orafce

   $ sudo docker build --build-arg OMNI_VERSION=OMNI_VERSION --tag google/alloydbomni-with-orafce:OMNI_VERSION .
   ```


3. Create a new container with AlloyDB Omni named `my-omni-orafce`:

   ```bash
   docker build -t google/alloydbomni-with-orafce:latest
   docker run --name my-omni-orafce  -e POSTGRES_PASSWORD=NEW_PASSWORD  -d google/alloydbomni-with-orafce:OMNI_VERSION
   ```
4. Connect to your database with the orafce extension:

   ```bash
   docker exec -it my-omni-orafce psql -h localhost -U postgres
   ```
5. Enable orafce:

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

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

   The output is similar to the following:

       postgres=# SELECT oracle.sysdate();
       sysdate
       ---
       2024-06-10 16:36:30
       (1 row)

   > [!NOTE]
   > **Note:** Due to some known issues with the orafce extension on AlloyDB Omni, we don't recommend that you use the `dbms_utility.format_call_stack`, `dbms_output.get_line`, and `regexp_*` functions.