Converting a H2 database to SQLite

1,378 views
Skip to first unread message

Cecil Westerhof

unread,
Sep 20, 2015, 1:01:34 PM9/20/15
to h2-da...@googlegroups.com
I need to convert a H2 database to SQLite. Are there tools to do this, or do I have to program it myself?

--
Cecil Westerhof

Mike Goodwin

unread,
Sep 20, 2015, 8:06:30 PM9/20/15
to h2-da...@googlegroups.com
I think the best your going to do is export to SQL and then reimport that (making any necessary compatability)

     SCRIPT TO 'export.sql'

    http://www.h2database.com/html/grammar.html#script

- mike


--
You received this message because you are subscribed to the Google Groups "H2 Database" group.
To unsubscribe from this group and stop receiving emails from it, send an email to h2-database...@googlegroups.com.
To post to this group, send email to h2-da...@googlegroups.com.
Visit this group at http://groups.google.com/group/h2-database.
For more options, visit https://groups.google.com/d/optout.

Cecil Westerhof

unread,
Sep 21, 2015, 12:59:31 AM9/21/15
to h2-da...@googlegroups.com
2015-09-21 2:06 GMT+02:00 Mike Goodwin <mkpgo...@gmail.com>:
I think the best your going to do is export to SQL and then reimport that (making any necessary compatability)

     SCRIPT TO 'export.sql'

    http://www.h2database.com/html/grammar.html#script

​I already use this for backups. I thought that there where differences between the SQL syntaxes, but I can always try. I will try this and let the result be known.
 
On Sun, Sep 20, 2015 at 6:01 PM, Cecil Westerhof <cldwes...@gmail.com> wrote:
I need to convert a H2 database to SQLite. Are there tools to do this, or do I have to program it myself?

--
Cecil Westerhof

Cecil Westerhof

unread,
Sep 21, 2015, 1:26:57 AM9/21/15
to h2-da...@googlegroups.com
2015-09-21 6:59 GMT+02:00 Cecil Westerhof <cldwes...@gmail.com>:
2015-09-21 2:06 GMT+02:00 Mike Goodwin <mkpgo...@gmail.com>:
I think the best your going to do is export to SQL and then reimport that (making any necessary compatability)

     SCRIPT TO 'export.sql'

    http://www.h2database.com/html/grammar.html#script

​I already use this for backups. I thought that there where differences between the SQL syntaxes, but I can always try. I will try this and let the result be known.
 
​It works better as I thought. I thought that SQLite only knew the data-types ​NULL, INTEGER, REAL, TEXT and BLOB. But changing:
    CREATE CACHED TABLE PUBLIC.AUTHORS(
        AUTHORID UUID NOT NULL,
        AUTHOR VARCHAR NOT NULL
    );
to
    CREATE TABLE authors(
        authorID UUID NOT NULL,
        author VARCHAR NOT NULL,
        PRIMARY KEY (authorID)
    );
seems to work.

I have to drop the CREATE USER.

For the insert I need to change:
    INSERT INTO PUBLIC.AUTHORS(AUTHORID, AUTHOR) VALUES
into:
    INSERT INTO authors(authorID, author) VALUES
But just removing PUBLIC. should be enough.

So it looks like it is manageable.

 
On Sun, Sep 20, 2015 at 6:01 PM, Cecil Westerhof <cldwes...@gmail.com> wrote:
I need to convert a H2 database to SQLite. Are there tools to do this, or do I have to program it myself?

--
Cecil Westerhof



--
Cecil Westerhof
Reply all
Reply to author
Forward
0 new messages