0

I have 5GB SQL dump and I want to import that to Postgres. I have one problem in SQL dump that is CREATE TABLE IF EXISTS. This is invalid in Postgres. I am unable to remove this line from that dump because that is huge in SIZE (5GB).

I am doing all these in Google Cloud. If there is any way to migrate from Google SQL to Postgres that will also work for me.

3
  • What kind of dump is that? How did you create it? Btw: create table if exists makes no sense whatsoever. Did you mean if NOT exists? Commented Apr 18, 2019 at 5:21
  • Are you trying to import a mysql dump into postgres? If so, the create if not exists is just one of many problems you will have Commented Apr 18, 2019 at 5:37
  • 1
    @JorgeCampos: create table if NOT exists is supported by Postgres. But not create table if exists (which doesn't make sense to begin with and wouldn't actually work) Commented Apr 18, 2019 at 6:26

1 Answer 1

1

As described in this article, you can export your data to a PostgreSQL dump using the pg_dump command. Command: pg_dump -U [USERNAME] --format=plain --no-owner --no-acl [DATABASE_NAME] | sed -E 's/(DROP|CREATE|COMMENT ON) EXTENSION/-- \1 EXTENSION/g' > [SQL_FILE].sql

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.