How to Migrate from Snowflake to MariaDB in PostgreSQL

Galaxy Glossary

How do I migrate data and schema from Snowflake to MariaDB?

Move data, schema, and routines from Snowflake to MariaDB using unload files, type mapping, and bulk-load commands.

Sign up for the latest in SQL knowledge from the Galaxy Team!
Welcome to the Galaxy, Guardian!
Oops! Something went wrong while submitting the form.

Description

Table of Contents

Why migrate from Snowflake to MariaDB?

Lower license cost, on-prem installation, and MySQL compatibility often drive teams to move analytics or OLTP workloads from Snowflake to MariaDB.

What are the high-level steps?

1) Extract Snowflake objects
2) Unload table data
3) Transform schema & data types
4) Bulk-load into MariaDB
5) Validate row counts & queries.

How do I export Snowflake data to external storage?

Use COPY INTO 's3://bucket/path/' FILE_FORMAT=(TYPE=CSV FIELD_OPTIONALLY_ENCLOSED_BY='"') to create compressed CSV files partitioned by table.

How do I generate MariaDB-ready CREATE TABLE scripts?

SELECT catalog metadata from INFORMATION_SCHEMA.COLUMNS, map Snowflake types (NUMBER → BIGINT, VARCHAR → VARCHAR, TIMESTAMP_NTZ → DATETIME), and emit CREATE TABLE DDL.

How can I preserve primary keys & indexes?

Snowflake doesn’t enforce keys, so manually add PRIMARY KEY and INDEX clauses in the generated DDL based on your application logic or foreign-key columns.

Which MariaDB bulk-loader should I use?

LOAD DATA LOCAL INFILE 'file.csv' INTO TABLE tab FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' LINES TERMINATED BY '\n' yields the fastest ingest when run with --local-infile.

How do I import an Orders table example?

1) COPY INTO '@~/orders.csv.gz' FROM Orders;
2) Download the file; gunzip it.
3) LOAD DATA LOCAL INFILE 'orders.csv' INTO TABLE Orders;

How do I migrate views and stored procedures?

Snowflake SQL differs from MariaDB; rewrite views with MySQL syntax and convert JavaScript or Snowflake Scripting procedures into MariaDB’s SQL/PSM.

How do I verify data integrity?

Run row-count checks (SELECT COUNT(*)) and sample aggregations (SUM, MIN, MAX) on critical columns in both systems and compare results.

Best practices for large datasets?

Split files by date or ID range, disable indexes during load, set innodb_buffer_pool_size high, and wrap loads in transactions to allow quick rollback.

Why How to Migrate from Snowflake to MariaDB in PostgreSQL is important

How to Migrate from Snowflake to MariaDB in PostgreSQL Example Usage


-- Move OrderItems to MariaDB
/* Snowflake side */
COPY INTO '@~/orderitems.csv.gz'
FROM OrderItems
FILE_FORMAT=(TYPE=CSV, FIELD_OPTIONALLY_ENCLOSED_BY='"');

-- MariaDB side */
CREATE TABLE OrderItems (
  id BIGINT PRIMARY KEY,
  order_id BIGINT,
  product_id BIGINT,
  quantity INT,
  INDEX (order_id),
  INDEX (product_id)
);

LOAD DATA LOCAL INFILE '~/orderitems.csv'
INTO TABLE OrderItems
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'
LINES TERMINATED BY '\n';

How to Migrate from Snowflake to MariaDB in PostgreSQL Syntax


-- 1. Unload Snowflake table to S3
COPY INTO 's3://company-eu/export/customers/'
FROM Customers
FILE_FORMAT=(TYPE=CSV, FIELD_OPTIONALLY_ENCLOSED_BY='"')
SINGLE=FALSE  -- create multiple chunks
OVERWRITE=TRUE;

-- 2. Equivalent MariaDB DDL after type mapping
CREATE TABLE Customers (
  id           BIGINT PRIMARY KEY,
  name         VARCHAR(255),
  email        VARCHAR(320),
  created_at   DATETIME
) ENGINE=InnoDB;

-- 3. Bulk-load file into MariaDB
LOAD DATA LOCAL INFILE '/exports/customers_0.csv'
INTO TABLE Customers
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'
LINES TERMINATED BY '\n';

Common Mistakes

Frequently Asked Questions (FAQs)

Can I use Snowflake’s UNLOAD instead of COPY INTO?

COPY INTO is Snowflake’s unload command; it writes to cloud storage. There is no separate UNLOAD function.

How do I handle TIMESTAMP_TZ columns?

Convert to UTC in Snowflake using ::timestamp_ntz AT TIME ZONE 'UTC' before export, then load into MariaDB DATETIME or TIMESTAMP.

Want to learn about other SQL terms?

Trusted by top engineers on high-velocity teams
Aryeo Logo
Assort Health
Curri
Rubie Logo
Bauhealth Logo
Truvideo Logo
Welcome to the Galaxy, Guardian!
Oops! Something went wrong while submitting the form.