← Every conversion

Convert a PostgreSQL schema to Amazon Redshift

Paste the CREATE TABLE statements from PostgreSQL and ERD Designer draws them as a diagram. Change the diagram's target database to Amazon Redshift and every column's datatype is converted. You review each change before it is applied, then generate the Amazon Redshift script.

You sign up free and land on your diagram. Your script is held for 15 minutes and deleted from our server the moment you open it.

What changes in the sample

Converted to Amazon Redshift, these columns of the sample above change type. Everything else keeps its type; names, keys, nullability and lists of allowed values are left as they are.

ColumnPostgreSQLAmazon RedshiftNote
customers.customer_idBIGSERIALBIGINT
customers.emailVARCHAR(255)CHARACTER VARYING(255)
customers.full_nameVARCHAR(120)CHARACTER VARYING(120)
customers.notesTEXTCHARACTER VARYING
customers.created_atTIMESTAMP WITH TIME ZONETIMESTAMPTZdefault: now() → CURRENT_TIMESTAMP
orders.order_idSERIALBIGINT
orders.public_idUUIDCHARACTER VARYING(36)default: gen_random_uuid() removed
orders.statusENUM (order_status)CHARACTER VARYING(7)
orders.totalNUMERIC(12,2)DECIMAL(12,2)
orders.placed_atTIMESTAMP(3)TIMESTAMP
orders.receipt_pdfBYTEACHARACTER VARYING

What it tells you

Where a conversion loses something, ERD Designer says so rather than picking for you. These are the messages for the sample:

The Amazon Redshift script

This is what ERD Designer generates for the sample, for Amazon Redshift. Our test suite applies this conversion to a real Amazon Redshift server and then reads the database back to confirm it matches the diagram exactly.

-- NOTE: Redshift does not enforce PRIMARY KEY, UNIQUE or FOREIGN KEY.
-- They are declared for the query planner, which TRUSTS them: a key that is
-- not actually unique will produce wrong results rather than an error.

-- Create table customers
CREATE TABLE "customers" (
  "customer_id" BIGINT NOT NULL,
  "email" VARCHAR(255) NOT NULL,
  "full_name" VARCHAR(120) NOT NULL,
  "notes" VARCHAR(256),
  "is_active" BOOLEAN NOT NULL DEFAULT TRUE,
  "created_at" TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP,
  CONSTRAINT "customers_PK" PRIMARY KEY ("customer_id")
)
DISTSTYLE AUTO;

-- Create table orders
CREATE TABLE "orders" (
  "order_id" BIGINT NOT NULL,
  "customer_id" BIGINT NOT NULL,
  "public_id" VARCHAR(36) NOT NULL,
  "status" VARCHAR(7) NOT NULL DEFAULT 'new',
  "total" NUMERIC(12,2) NOT NULL,
  "placed_at" TIMESTAMP NOT NULL,
  "receipt_pdf" VARCHAR(256),
  CONSTRAINT "orders_PK" PRIMARY KEY ("order_id")
)
DISTSTYLE AUTO;

-- Add unique constraint on customers (email)
ALTER TABLE "customers" ADD CONSTRAINT "customers_UQ1" UNIQUE ("email");

-- Add foreign key orders (customer_id) → customers (customer_id)
ALTER TABLE "orders" ADD CONSTRAINT "orders_FK1" FOREIGN KEY ("customer_id") REFERENCES "customers" ("customer_id");

How to convert your own schema

  1. Paste your PostgreSQL script above and press Open in ERD Designer. The diagram opens laid out and ready to edit.
  2. Click the diagram's name in the toolbar to open its properties, choose Amazon Redshift under Target Database / Version, and press Apply Changes.
  3. If Amazon Redshift offers more than one way to store a kind of column, choose one and press Continue.
  4. Read the list of retyped columns and any warnings, then press Apply Conversion. Save the diagram to keep it.
  5. Press Generate DDL (the database icon) to copy or download the Amazon Redshift script — or apply it to a database on your own network with the ERD Designer Agent.

What it reads, and what it does not

Which plan you need

Pasting a script and working with it as a diagram is free on the Basic plan, with no card. Converting a diagram to another database is part of the Pro and Advanced plans, which also generate its script and can apply it through the Agent.

Other conversions

Questions? Write to support@erddesigner.com. · ERD Designer · Terms · Privacy