How to Migrate from BigQuery to Oracle

Galaxy Glossary

How do I move data from Google BigQuery to Oracle quickly and safely?

Move data, schema, and routines from Google BigQuery to Oracle using export, transform, and load steps.

Sign up for the latest in SQL knowledge from the Galaxy Team!
Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.

Description

Why move data from BigQuery to Oracle?

Teams consolidate analytics and OLTP workloads, cut cloud costs, or join Oracle-only systems. Oracle offers mature ACID transactions, partitioning, and on-prem control.

Which migration paths exist?

Three practical options: 1) CSV/Parquet export + SQL*Loader, 2) BigQuery → Cloud Storage → Oracle External Tables, 3) Oracle Database Gateway for BigQuery with INSERT SELECT over DB Link.

How do I export BigQuery tables efficiently?

Use bq extract with compressed Parquet to Cloud Storage.Parquet preserves data types and is splittable for parallel load.

bq extract --destination_format=PARQUET \
--compression=SNAPPY \
ecommerce.Orders gs://bq_oracle_stage/Orders_*.parquet

How do I create matching Oracle tables?

Map BigQuery types to Oracle equivalents before load. Example: STRING → VARCHAR2, INT64 → NUMBER, TIMESTAMP → TIMESTAMP(6).

CREATE TABLE Orders (
id NUMBER PRIMARY KEY,
customer_id NUMBER REFERENCES Customers(id),
order_date DATE,
total_amount NUMBER(14,2)
);

What is the load command syntax?

SQL*Loader and external tables share a control file syntax.External tables avoid staging into redo logs, saving space.

CREATE TABLE ext_orders
ORGANIZATION EXTERNAL (
TYPE ORACLE_LOADER
DEFAULT DIRECTORY gcs_stage
ACCESS PARAMETERS (
records delimited by newline
preprocessor gcs_parquet
)
LOCATION ('Orders_001.parquet', 'Orders_002.parquet')
)
REJECT LIMIT UNLIMITED;

How do I merge data into live Oracle tables?

Use INSERT APPEND for new tables or MERGE for incremental syncs.

INSERT /*+ APPEND */ INTO Orders SELECT * FROM ext_orders;

Can I migrate in one hop?

Yes.Configure Oracle Database Gateway for BigQuery, create a DB Link, then pull data.

INSERT /*+ PARALLEL(8) */ INTO Orders
SELECT * FROM Orders@BG_LINK;

How do I validate the migration?

Row counts: compare SELECT COUNT(*). Check aggregates like SUM(total_amount).Hash columns for spot checks.

Best practices for large datasets?

Split exports by date, leverage parallel SQL*Loader, disable indexes/constraints during bulk loads, and enable Oracle Direct Path.

Next steps after data load?

Rebuild indexes, gather statistics (DBMS_STATS), recreate views, and port UDFs to PL/SQL.

Common BigQuery-to-Oracle data type mappings

STRING → VARCHAR2(4000), BYTES → RAW, NUMERIC → NUMBER(38,9), BOOL → NUMBER(1), DATE → DATE, STRUCT → JSON.

How to handle partitioned tables?

Create matching Oracle Range or Interval partitions, export each BigQuery partition to its own file, and load in parallel.

Orders partition example

CREATE TABLE Orders (
...
) PARTITION BY RANGE (order_date) (
PARTITION p2023 VALUES LESS THAN (DATE '2024-01-01'),
PARTITION pmax VALUES LESS THAN (MAXVALUE)
);

Automating the workflow?

Wrap export, upload, and load steps in Cloud Build or Airflow, passing file lists to SQL*Loader via templates.

Security considerations?

Encrypt files in transit (gsutil --sse), restrict GCS access, and purge stage files after load.In Oracle, load into staging schema with limited privileges.

Performance tuning tips?

Increase SQL*Loader PARALLEL, use DIRECT=TRUE, and adjust Oracle PGA_AGGREGATE_LIMIT to sustain throughput.

Monitoring progress?

Track Cloud Storage object counters, SQL*Loader log files, and Oracle v$session_longops to estimate time remaining.

.

Why How to Migrate from BigQuery to Oracle is important

How to Migrate from BigQuery to Oracle Example Usage


-- Migrate 'Products' table
bq extract --destination_format=CSV \
  --field_delimiter="," --print_header=false \
  ecommerce.Products gs://bq_oracle_stage/Products.csv

-- Control file: products.ctl
LOAD DATA
INFILE 'Products.csv'
INTO TABLE Products
FIELDS TERMINATED BY ','
(id INTEGER EXTERNAL,
 name CHAR,
 price DECIMAL EXTERNAL,
 stock INTEGER EXTERNAL)

-- Run loader
sqlldr userid=migrator/secret control=products.ctl parallel=true direct=true

How to Migrate from BigQuery to Oracle Syntax


-- 1. Export from BigQuery to Cloud Storage (Parquet recommended)
bq extract --destination_format=PARQUET --compression=SNAPPY \
  ecommerce.Orders gs://bq_oracle_stage/Orders_*.parquet

-- 2. Create Oracle Directory pointing to GCS bucket
CREATE DIRECTORY gcs_stage AS 'bq_oracle_stage/';
GRANT READ, WRITE ON DIRECTORY gcs_stage TO migrator;

-- 3. Define External Table mapping
CREATE TABLE ext_orders
ORGANIZATION EXTERNAL (
  TYPE ORACLE_LOADER
  DEFAULT DIRECTORY gcs_stage
  ACCESS PARAMETERS (
    records delimited by newline
    preprocessor gcs_parquet
  )
  LOCATION ('Orders_*.parquet')
);

-- 4. Create final table with correct data types
CREATE TABLE Orders (
  id           NUMBER PRIMARY KEY,
  customer_id  NUMBER,
  order_date   DATE,
  total_amount NUMBER(14,2)
);

-- 5. Load data
INSERT /*+ APPEND */ INTO Orders SELECT * FROM ext_orders;

-- 6. Validate counts
SELECT (SELECT COUNT(*) FROM Orders) AS oracle_count,
       (SELECT COUNT(*) FROM `ecommerce.Orders`) AS bq_count;

Common Mistakes

Frequently Asked Questions (FAQs)

Can I keep BigQuery and Oracle in sync?

Yes. Schedule daily exports of changed partitions or use Oracle GoldenGate for BigQuery to replicate CDC streams.

How do I migrate views and UDFs?

Convert BigQuery views to Oracle views manually; translate JavaScript UDFs into PL/SQL functions. Test with sample rows.

Is downtime required?

No. Export snapshots, backfill, then switch applications to Oracle once validation passes. Use incremental loads for last-minute changes.

Want to learn about other SQL terms?